Monthly Archives: January 2014

Query all content, except the currently viewed post

This is a great snippet for WordPress, usually used in a sidebar for featured content. If you were looking at a post of some type of content, you could stop that same post from being listed in the sidebar as well by using this code.

$this_post = $post->ID;
$args = array( 'post_type' => 'career', 'post__not_in' => array($this_post), 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="entry-content">';
echo '</div>';