Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

definitive

macrumors 68020
Original poster
Aug 4, 2008
2,088
1,020
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:

Code:
<ul>
<?php $posts = get_posts( "category_name=name_of_menu&numberposts=4&orderby=date&order=ASC" ); foreach($posts as $post) : ?>

<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>

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

Code:
.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

Code:
<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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.