Highlight the year in archive navigation by year
I’d love some help on this I’ve been through the forums and codex at length to try and get a solution!
I have an archive navigation which is a list of years:
<?php $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts ORDER BY post_date DESC"); foreach($years as $year) : ?> <li><a <?php if (is_page('$year') ) echo('class="onpage" '); ?> href="<?php echo get_year_link($year); ?> "><?php echo $year; ?></a></li> <?php endforeach; ?>
this spits out the url http://www.domain name.com/2012 and uses the archive.php page
I can not get the archive navigation 2010 to highlight when you are on the 2012 page.
I’ve tried is_archive but that just highlights all the links!
Is there a way to do this?
Thanks so much!
- The topic ‘Highlight the year in archive navigation by year’ is closed to new replies.