• Resolved axeldev

    (@axeldev)


    Hello all!

    I’m developing my first site with TwentyEleven theme on my local machine and so far successfully set up a secondary menu, which I’ve styled via my child theme CSS and added to the Custom Menu widget.

    Here’s where I’m stuck:

    1. Using Widget Logic I’ve so far been unable to restrict the pages where the secondary menu is shown. I only want to show the secondary menu on 1 page and its child pages – nowhere else on the site.

    I’ve used this code but no joy:

    is_page(‘stories’) && global $post; return in_array(33,get_post_ancestors($post)));

    (page slug is ‘stories’ and its page id is 33)

    I also tried to test this by only showing the widget on the homepage using the simpler is_home(); however doesn’t seem to work either.

    2. I’ve styled the secondary menu and it all looks ok. However I would like to create an association between both menus such that when I click on a page in the secondary menu it recognises that I am still in the same section by highlighting ‘Stories’ in the primary menu.

    e.g. Primary Menu Items: Home Stories Blog
    Secondary Menu: All Cats Dogs

    – All items in secondary menu are below Stories
    – When I click on All / Cats / Dogs I would like to highlight ‘Stories’ in the primary menu

    I hope this makes sense! A big thank you in advance to anyone who’s kind enough to help and apologies if there is any confusion…

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    1. Why use Widget Logic at all if you;re going to delve into the child theme’s code anyway. The easiest way to approach this is to create a custom page template that calls in the secondary menu via <?php get_sidebar( 'foo' );?> and then apply the new template to the 1 parent page and all of its children.

    2. Have you looked at styling on the current_page_ancestor class?

    Thread Starter axeldev

    (@axeldev)

    Hi Esmi,

    Thank you very much for replying so quickly! This is extremely helpful and I guess shows how much I still need to learn ??

    I’m going to look at both of these now and hopefully find my way.

    Thanks again!

    esmi

    (@esmi)

    No problem ??

    Thread Starter axeldev

    (@axeldev)

    Well thanks to your help I managed to style my menus as I wanted (point 2).

    This post was also helpful for anyone else looking at this issue:
    https://wordpress.stackexchange.com/questions/29280/current-page-ancestor-broken-in-twenty-eleven

    In it one user suggested using hyphens (current-page-ancestor), not underscores with the TwentyEleven theme… It worked for me.

    Now back to my custom page template…

    esmi

    (@esmi)

    My bad. Some of the classes generated on menus have hyphens, others have underscores and I do sometimes mix them up. I wish they’d standardise them!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Associate Primary vs Secondary Menu in TwentyEleven / Widget Logic’ is closed to new replies.