Can anyone help?
I’ve got the following code in an include file on my single.php page to display the posts from the category ‘Archive’;
<div id="newsArchivePanel"> <h2><a href="/category/archive/">News Archive</a></h2> <ul> <?php $IDOutsideLoop = $post->ID; global $post; $myposts = get_posts( array ( 'category_name' => 'Archive', 'posts_per_page' => 3 ) ); foreach($myposts as $post) : ?> <li <?php if(is_single() && $IDOutsideLoop == $post->ID) print 'class="currentPost"' ?>><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></li> <?php endforeach; ?> </ul> </div>
However, I am also using the same code to highlight the post title in the ‘latest news category’.
The post title highlighting works for the Latest News list, but not the archive list when viewing an archived post.
Is there a way of combining these two sets of code at all to make them both work?
- The topic ‘Highlighting current post title in get_posts list’ is closed to new replies.