Do you want all new topics get assigned to the same menu, or new topics assigned to different menus depending on say which forum they are created in?
Hi Robin,
thanks answering me ๐
I want all new topics created in a forum takes the menu of this forum.
For exemple :
MENU 1 ON :
SITE 1
– FORUM 1
— TOPICS
— TOPICS
***********************
MENU 2 ON :
SITE 2
– FORUM 2
–TOPICS
–TOPICS
etc…
Do you understand what i’m tring to say ? :p I hope you can understand my english ๐
Thanks in advance !
Here is my research :
I register the forum parent id with this :
$parents = get_post_ancestors( $post->ID );
$id = ($parents) ? $parents[count($parents)-1]: $post->ID;
$parent_id = "forum_parent_".$id;
and add it on my body class
<?php body_class($parent_id." ".$style." ....) ?>
and then i creat this little function :
if (bbp_is_single_topic($parent_id === ‘forum_parent_11801’)){
wp_nav_menu(array(‘theme_location’ => ‘primary’, ‘menu’=>’my-menu-name’ ));
}
It doesn’t work but i think that i’am not so far from what i want !
without looking further, I’d suggest
if (bbp_is_single_topic($parent_id) === โforum_parent_11801โ){
or
if (bbp_is_single_topic(โforum_parent_11801โ){
but I’d need to look at the function further if that doesn’t work, do come back
although
`$forum_id = bbp_get_topic_forum_id($post_id);
or
$forum_id = bbp_get_topic_forum_id($post_id);
`
would be quicker and easier to get the forum id
Hi Robin,
and thanks again answering me ๐
$forum_id = bbp_get_topic_forum_id($post_id);
This line don’t get the parent forum, it get the current forum. Cause i created forums -> subforum -> topics
I change a little my function, and now this is perfect, the menu is displayed on the right forum and all his topics.
But now my problem is that this menu is displayed on the top of my page and not instead of the main menu of wordpress…
here is my new function :
`if (bbp_is_single_topic() && $parent_id == ‘forum_parent_11801’){
wp_nav_menu(array(‘theme_location’ => ‘avia’, ‘menu’=>’menu-frenchtis-life’ ));
}
Do you know how can i replace the main menu by the good one ?
in the function i right :
‘theme_location’ => ‘avia’
This line must place my menu instead of the main menu no ?
ok, this is now a wordpress problem, so suggest you post a new topic there
Support Forums
I am looking to do just what the original poster was looking for:
When a user creates a new topic, the menu assigned to this new topic should be the same menu as the forum. It is currently using the default WordPress menu. Can someone point me to the right code and where to add it to automatically assign the right menu to new topics? I appreciate your help.