Exclude Current Post from Query
-
I have a sidebar that is pulling in related blog posts by tags but it is showing the current post in the sidebar instead of just pulling two random posts.
Sample page: http://staging.rswcreative.com/four-signs-that-mobile-learning-is-on-the-rise/
This is the code that I think needs to be edited.
<aside id="news-entry-sidebar"> <div id="related-case-header">Related Case Studies</div> <?php $posttags = get_the_tags(); $test = ''; $sep = ''; if ($posttags) { foreach($posttags as $tag) { $test .= $sep . $tag->name; $sep = ","; } } query_posts('tag=' .$test . '&showposts=1'); while (have_posts()) : the_post(); ?> <div class="post-page-work-entry"> <?php the_post_thumbnail(); ?> <p style="line-height: 110%;"><?php the_field('client'); ?><br /> <?php the_title(); ?><br /> <span style="color: #888888; font-size: 16px;"><?php the_field('project_type'); ?></span></p> <p class="post-page-work-entry-excerpt"><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>"></a></p> </div> <?php endwhile; wp_reset_query(); ?> </aside>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Exclude Current Post from Query’ is closed to new replies.