WordPress question regarding Categories and Posts.

Discussion in 'Web Design and Development' started by definitive, Dec 27, 2012.

  1. macrumors 68000


    Aug 4, 2008
    I'm currently trying to make a menu on a page which would display a vertical list of four items. These items are post names which belong to a category named "name_of_menu".

    Here's the code for the loop so far:

    <?php $posts = get_posts( "category_name=name_of_menu&numberposts=4&orderby=date&order=ASC" ); foreach($posts as $post) : ?>
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    <?php endforeach; ?>
    What I'm trying to do is have the active page's (since these 4 items will be repeated across the 4 pages) hyperlink be a different color from the rest.

    If I use something like

    .current_page_item > a,
    .current-post-ancestor a,
    .current_page_ancestor > a {
    	color: #aabbcc;
    and add the class to the <li> in the code above, then it makes all the topic hyperlinks that color instead of the active page's. I also tried

    <li><?php if (is_home()){echo " class="current_page_item";}?>>
    as well, but that doesn't work correctly either.

    Anyone ever deal with this issue before and could provide some help?

Share This Page