WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Formatting and Template Tags (2 posts)

  1. kennethwatt
    Member
    Posted 5 years ago #

    Hi guys
    I have this code:

    <div id="masthead_image">
    
            <ul>
            <li <?php if(is_front_page()) { ?>class="current_page_item"<?php } ?>><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    		<?php wp_list_pages('sort_column=menu_order&title_li=' ); ?>
    		<?php wp_list_categories('orderby=name&title_li='); ?>
          </ul>
    
          </div>

    and the CSS:

    div#masthead ul li a {
    color:#35044c;
    text-decoration:none;
    display:block;
    font-size:1.3em;
    font-weight:700;
    text-transform:uppercase;
    height: 40px;
    width:150px;
    }
    
    div#masthead ul li a:hover,div#masthead ul li.current_page_item {
    background:#00ff00;
    }

    I understand why the home button is shown as active, as there is the query in the code. But why does the page get shown as active, but the categories don't?
    Live version: http://www.forecourt.org.uk

    Thanks in advance :-)

  2. microcipcip
    Member
    Posted 5 years ago #

    Hi, if you look the source code when you click on a category link, you can see that there is this class: current-cat, so I guess that you should add this in the second declaration in the CSS file.

Topic Closed

This topic has been closed to new replies.

About this Topic