Support » Themes and Templates » Styling current_page_item in menu doesn’t work

  • Resolved xith


    Having some trouble with my menu–any help much appreciated!

    My sidebar div consists of

     <?php wp_page_menu('show_home=1&amp;sort_column=menu_order'); ?>

    In a view source, this shows up as

    <li ><a href="">Home</a></li>
    <li class="page_item page-item-4"><a href="" title="Contact">Contact</a></li>
    <li class="page_item page-item-68 current_page_item"><a href="" title="Titles">Titles</a></li>

    Etc., including more links.

    Two questions:
    1. I’ve been attempting to style the class “current_page_item” to change the color of the current page, but every way I’ve gone about trying to do it, nothing happens at all. The only color comes from #menu a:link, #menu a:visited in the css.

    2. The WP code for the menu ads these classes to the pages, but not to the link to the home page, so even if I get the style to work, it won’t affect the home page. Any way to change this?


Viewing 4 replies - 1 through 4 (of 4 total)
  • hey i’ve never tried that code before but i’m using other code givr it a try it’s much easier:

    <li<?php if (is_home()){echo " class=\"current_page_item\"";}?>><a href="<?php bloginfo('url') ?>" title="Home">Home</a></li>
    <?php wp_list_pages('title_li='); ?>

    then just style your .current_page_item

    hope this helps

    Thanks. I tried that out and it works for displaying the list, but styling .current_page_item still isn’t doing anything. I’m not sure if I’m encountering a problem with WP coding or just messed something up in my style sheet (I’m more familiar with CSS than with WP, but by no means an expert).

    definitely its the css,

    #menu ul li.current_page_item a

    your structure should look something like the above. Notice that li is attached to .current_page_item

    That was it. Thanks so much! I’ll remember that for next time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Styling current_page_item in menu doesn’t work’ is closed to new replies.