WordPress.org

Ready to get started?Download WordPress

Forums

Menu issue for months, no answer yet...Anybody? (6 posts)

  1. xiabolai
    Member
    Posted 4 years ago #

    I am using dynamic menu highlighting as suggested in the wordpress codex.

    It is working on almost all of my pages. However, I have a portfolio section called 'Work' with multiple sub categories and I cannot get the subcategories and single posts within these subcategories to highlight the main portfolio 'Work' link.

    Here is what I mean. I have a top level menu link of 'Work'. Within that there are subcats of interactive, print, outdoor, etc, etc.

    when I am in a subcategory or post of one of the subcategories of the main portfolio 'Work' link itself I want the 'Work' link to be highlighted. This is the code I am using:

    <li<?php
                   if (is_category(array('interactive','microsite','email','print'))
                    {
                    echo " id=\"current\"";
                    }?>>
                    <a>Work</a>
    <ul>
        			<?php wp_list_categories("exclude=$blog_ID&title_li="); ?>
        		</ul>
            </li>

    This is giving me an error. I can sort of see why....but I don't know how to correct it. Would I need to use an elseif statement within this particular list item?

    Here's the site: http://newsite.blairshapiro.com

    Any help would be hugely appreciated!

  2. iridiax
    Member
    Posted 4 years ago #

    if (is_category(array('interactive','microsite','email','print'))

    The above has a missing )

    I always use this general format so that I can use regular code:

    <?php if (is_category('a')) { ?>
    <!-- code here -->
    
    <?php } elseif (is_category(array('b','c'))) { ?>
    <!-- code here -->
    
    <?php } elseif (is_category('d')) { ?>
    <!-- code here -->
    
    <?php } else { ?>
    <!-- code here -->
    
    <?php } ?>
  3. iridiax
    Member
    Posted 4 years ago #

  4. xiabolai
    Member
    Posted 4 years ago #

    Hi,

    Thanks for the response. I'm somewhat of a newbie, and not sure I understand how to implement your suggestion, or the codex examples which look like they may be right on target.

    Any way you can show me an example of exactly what the code might look like to achieve my goal?

  5. iridiax
    Member
    Posted 4 years ago #

    If it were me, I would style li.current-cat and li.current-cat-parent in my theme's style.css. I'm not sure what could do on individual post pages since these are not categories, probably something with in_category and current_category in wp_list_categories.

  6. xiabolai
    Member
    Posted 4 years ago #

    Thanks for the reply.

    So if I use the css route, I don't have to do anything to the php?

Topic Closed

This topic has been closed to new replies.

About this Topic