Home Forums Weaver Xtreme Theme Alternate Menu for single post pages

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #71756
    Cactus
    Participant

    When defining an Alternate Primary Menu and using this also for the blog page, that’s fine using the Weaver show posts filters. But then, when opening the post, on the single post page the menu returns to the default main menu. No way to modify the menu for the post to the alternate menu. Is it just me, or is this feature actually missing in Weaver Xtreme?

    #71761
    scrambler
    Moderator

    There is indeed no option to replace the menu on single post pages.

    That said, we can do it with a bit of Custom CSS.

    Given you have the Xtreme Plus Plugin, you can insert the alternate menu where you need it using one of the insertion are or widgets, then we can hide that everywhere, but unhide it on single post pages using CSS, and at the same time, we can hide the regular menu on single post pages using CSS.

    If you give us a link to a single post page, we can suggest the best area to use to insert the menu and the CSS to use to do the above

    #71783
    Private Reply
    Cactus
    Participant
    This reply has been marked as private.
    #71784
    scrambler
    Moderator

    The suggestion to add Custom menus on post editing page option would be for @weaver who is the theme developer.

    You should post it in the Feature suggestion sub forum so it does not get lost for next time he decides to add features!

    If interested in a workaround like I mentioned, you would need to confirm which menu you are trying to replace, because if I go to the home page or the blog page or a post page, they all have the same menu at the top.

    Is the fixed menu at the top on a post page the one you want to change for all single post pages?

    #71785
    scrambler
    Moderator

    To replace the top fixed menu on your single post pages you can do the following

    Add the shortcode for the extra menu you need in the Adavanced Options > HTML insertion areas > Pre Wrapper code box.
    Replacing NameOfMenu by your Custom menu name
    [extra_menu menu_name='NameOfMenu' menu_style='primary' menu_type='standard']

    In the BG CSS+ box of that area below, add the following rule to fix the area, place it on top, and make it full width
    {position:fixed;z-index:20000;width:100%;}

    Then in the theme Global Custom CSS Rule box, add the following CSS
    #inject_prewrapper {display:none;}
    .single #inject_prewrapper {display:block;}
    .single #nav-primary {display:none;}
    #wrapper {padding-top:87px;}

    That will hide the pre wrapper area everywhere except the single post pages, hide the regular primary menu on these same single post pages, and create the space for the new fixed menu at the top of the wrapper.

    If for some reason it does not quite work, leave all the elements in place and post back with the issue.

    #71796
    Private Reply
    Cactus
    Participant
    This reply has been marked as private.
    #71798
    scrambler
    Moderator

    You can still use similar methods to achieve that result. Depending on what you prefer, there would be two methods

    Method 1 (listing all posts for each menu):
    You would simply replace the single shortcode in the pre wrapper by a list of show_if shortcodes each containing an extra menu shortcode that will show a specific menu only on a specific list of posts

    [show_if post_id=xxx,yyy,zzz ][extra_menu menu_name='NameOfMenu1' menu_style='primary' menu_type='standard'][/show_if]
    [show_if post_id=xxx,yyy,zzz ][extra_menu menu_name='NameOfMenu2' menu_style='primary' menu_type='standard'][/show_if]

     

    Method 2 (creating a class of posts for each menu):
    In that case you could use the “Per post body class” option in the post editing page Xtreme plus tab to give posts a family class
    For example some posts would be given the class mysales, others myposts, others mydiscussion ….

    Then you would put all the extra menu shortcodes in the pre wrapper area, adding the corresponding class to each custom menu like below
    [extra_menu menu_name='NameOfMenu1' menu_style='primary' menu_type='standard' class='mysales']
    [extra_menu menu_name='NameOfMenu2' menu_style='primary' menu_type='standard' class='myposts']
    [extra_menu menu_name='NameOfMenu3' menu_style='primary' menu_type='standard' class='mydiscussion']

    Then you would change the CSS I gave you to the following, in order to hide all menus, then unhide the proper menu on the proper pages
    #inject_prewrapper {display:none;}
    .single #inject_prewrapper {display:block;}
    .single #nav-primary {display:none;}
    #wrapper {padding-top:87px;}
    #inject_prewrapper .wvrx-menu-container {display:none;}
    .mysales #inject_prewrapper .wvrx-menu-container.mysales {display:block;}
    .myposts #inject_prewrapper .wvrx-menu-container.myposts {display:block;}
    .mydiscussion #inject_prewrapper .wvrx-menu-container.mydiscussion {display:block;}

    Again, these are workarounds, remember to submit your suggestion in the suggestion forum so @weaver can see it whenever he is looking to add features

    #71799
    Cactus
    Participant

    Thank you. I think I will try your Method 2.

    #71800
    Private Reply
    Cactus
    Participant
    This reply has been marked as private.
    #71802
    scrambler
    Moderator

    Yes my bad, did not realize @weaver had closed the suggestion forum.

    By now he has seen that thread, so if he will be able to decide if adding Custom menu selection per Single post page is to be considered

    #71803
    Weaver
    Keymaster

    I looked into this idea, and I don’t think it is feasible to do given a fundamental way menu handling has been implemented within Weaver Xtreme. And I don’t remember ever getting another request for this feature before.

    The way Weaver handles special pages like the Single page, Search page, and perhaps a couple others, there isn’t a particularly logical way to add special options for such pages.

    However, there is a bit easier workaround for your case than using an extra menu. Define primary and secondary menus with the secondary menu intended to show only on the Single page. Set so that both primary and secondary menus are displayed next to each other in the Header settings. As usual, set the primary and secondary to the menus you define in the dashboard menu option.

    Add this global custom CSS:

    #nav-secondary {display:none;}
    .single #nav-secondary{display:initial !important;}
    .single #nav-primary {display:none;}

    The negative of this approach is that both of primary and secondary menu HTML will be generated for every page. This will have little or no effect on page loading in reality.

    You could also implement a child theme with custom PHP codes for single.php. That is a bit beyond the kind of help we’ve provided on this site before – you are pretty much on your own for child themes.

     

     

    #71804
    scrambler
    Moderator

    @weaver, for one different menu for all single post pages, your solution is indeed simpler 🙂

    Unfortunately, he actually needs different menu on different posts, so the 2 menus approach was not sufficient and why I gave him a more complete workaround on my last post.

    #71808
    Weaver
    Keymaster

    Ok.

    Trying to select a different single page menu based on specific posts really does seems like it would be very hard as well as not very generally useful which is one major requirement for adding features.

    #71825
    hkp
    Participant

    @Cactus @Scrambler

    I use a plugin called “List Category Posts” (LCP) which sorts my lists by Category; Author; Date; etc. and provides shortcodes to place where needed, as in: [catlist name=”news” date=2019 author=”John”]

    When using Scrambler’s Method 1, [show_if post_id=xxx,yyy,zzz ] etc., one will need to updated this code for each future added post.

    I was wondering if, by adding in LCP shortcodes, could Scrambler’s Method 1 be made future-proof, by using the LCP customized list categories?

    e.g.
    [show_if catlist name =”news” date=2018 author=”John”][extra_menu menu_name='Na… 1 etc etc....]
    [show_if catlist name =”news” date=2019 author=”John”][extra_menu menu_name='Na… 2 etc etc....]

    I have not tried it, but it seems a useful resource to consider, for once it is set, all future posts will have the correct custom menu assigned automatically.

    Regards and thanks,
    Angus

    #71826
    scrambler
    Moderator

    The show_if shortcode shortcode can only sort by devices, post/page ID, login status, WP role.

    There is no way to add other criteria like the catlist plugin

    #71829
    hkp
    Participant

    Thanks Scrambler, I did not know that.

    However, your Method 1 will certainly work on a page of posts sorted by LCP.  But that is not what is requested….

    FYI, I also found this article: “How to Add WordPress Navigation Menu in Posts / Pages” which offers a plugin to insert a menus in posts.

    In their video, sadly, the “menu” is just a < ul > list, which, while CSS customizable, is certainly not akin to a Primary Menu in appearance.

    This plugin link offers much the same, but saves watching the video.  See Here.

    Regards and thanks.

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.