Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a query like this;

                        <?php $temp_query = $wp_query; ?>
                    <?php foreach(get_the_category() as $category) {
                        $cat = $category->cat_ID; }
                        query_posts('orderby=date&cat=' . $cat . '&order=desc&posts_per_page=-1'); 
                    ?>

It grabs all the posts from the current category.

What i then do with this information is create a list of all the thumbnails associated with those posts.

What i would like to do is highlight in some way, the current post. (through a class or something), something that is obviously done automatically normally.

Thanks Alex

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

save the main current post id into a variable and compare it in the loop with the current post id; example:

<?php $this_post = $post->ID; ?>
  <?php $temp_query = $wp_query; ?>                     
  <?php foreach(get_the_category() as $category) {                         
  $cat = $category->cat_ID; 
  }                         
query_posts('orderby=date&cat=' . $cat . '&order=desc&posts_per_page=-1');  
while( have_posts() ) : ?>
  <span<?php if( $this_post == $post->ID ) { echo ' class="current"'; } ?>>
   /*output of your posts here*/
  </span>
<?php endwhile;                    
?>
share|improve this answer
    
Perfect! What would i do without you guys?! –  Infocentre Jul 19 '11 at 8:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.