WordPress.org

Support

Support » How-To and Troubleshooting » Dynamic Menu Question

Dynamic Menu Question

  • BritneyJackson
    Member

    @britneyjackson

    Morning,

    I wondered if anyone was able to offer me some advice. I am trying to create a dynamic menu (see below) but I am running into a problem, the code below highlights ‘News’ if on single.php, archive & archive-2 pages.

    <li <?php if ( is_page("archive") || (is_page("archive-2") || (is_single()))) { echo 'class="current_page_item"';} ?>><a href="<?php bloginfo('url'); ?>/archive/">News</a></li>

    Now I want to create another menu item for ‘gig’ using the code below, but because the category post uses single.php it highlights the menu as ‘news’ because single.php is used in the ‘news’ menu item. Is there a way to trick WP into showing ‘gigs’ highlighted instead of ‘news’ when viewing a category post using single.php?

    <li <?php if ( is_category("9") || (is_page("gigs"))) { echo 'class="current_page_item"';} ?>><a href="<?php bloginfo('url'); ?>/gigs/">Gigs</a></li>

    Many thanks for any assistance you can offer 🙂

  • The topic ‘Dynamic Menu Question’ is closed to new replies.