Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread Display Modes
Old Dec 27, 2012, 04:48 PM   #1
macrumors 65816
Join Date: Aug 2008
WordPress question regarding Categories and Posts.

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?
definitive is offline   0 Reply With Quote

MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 05:05 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC