Skip to:
Content
Pages
Categories
Search
Top
Bottom

Different navigation menu on each forums and his child

  • @aztix

    Participant

    Hello community !

    First of all, I want to clarify that I’m french, so I apologize for my poor English !

    I explain my problem :

    I create a website with wordpress. A website that contains several little websites.
    Each little website has a different navigation. To do this I use the plugin : Zen menu logic, which allows me to select the right menu assigned for each page/post/forum/topic/reply of my website. Ok.

    The problem I have is the following :
    when a user creates a new topic, the menu assigned to this new topic, is the main menu of wordpress.
    at that time I could go in the wordpress admin, select the new subject which has just been created, and then assign the right menu but I want this operation to be automated !

    So do you know how I could do to automatically assign the right menu to a forum and all its sub forum / topic ?

    I tried many things but in vain !
    Does someone have an idea ?

    Thx a lot in advance !

Viewing 8 replies - 1 through 8 (of 8 total)
  • @robin-w

    Moderator

    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?

    @aztix

    Participant

    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 !

    @aztix

    Participant

    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 !

    @robin-w

    Moderator

    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

    @robin-w

    Moderator

    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

    @aztix

    Participant

    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 ?

    @robin-w

    Moderator

    ok, this is now a wordpress problem, so suggest you post a new topic there

    Support Forums

    @tvirtual

    Participant

    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar