Offset Current Post
-
I’ve been trying to find a plugin that displayed related posts via category, and was unable to do so. The next issue was finding a plugin that let me display the related posts via thumbnails instead of the title.
So I have finally found a solution by using some php trickery, mind you I’m mediocre at php at best and so this is my hack and slash job of getting a feature that has eluded me.
Here is the code:
<?php if ( in_category('1') ): ?> <?php query_posts('showposts=5&cat=1'); ?> <?php while (have_posts()) : the_post(); ?> <div class="recent-posts"> <div class="ratings-duh"><?php if(function_exists('the_ratings')) { the_ratings(); } ?> </div> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo get_settings('home'); ?>/wp-content/uploads/<?php $values = get_post_custom_values("thumb_image"); echo $values[0]; ?>" alt="<?php the_title(); ?>" /></a> </div> <?php endwhile; ?> <?php endif; ?>This basically pulls the recent posts from the post’s category and views them as a thumbnail. However it also pulls the post that you are currently on if it falls under the top 5 latest post in that category. Is there a way to offset the query to not pull the post it’s on? Hope this makes sense. Thanks in advance.
The topic ‘Offset Current Post’ is closed to new replies.