Skip to content

Instantly share code, notes, and snippets.

@adamlaki
Created June 30, 2018 16:05
Show Gist options
  • Save adamlaki/62ce18e33619a5d39793daf2550aa6af to your computer and use it in GitHub Desktop.
Save adamlaki/62ce18e33619a5d39793daf2550aa6af to your computer and use it in GitHub Desktop.
Exclude Current Post from WP_Query
<?php
$args = array (
'post_type' => array( 'jobs' ),
'nopaging' => false,
'posts_per_page' => '5',
'ignore_sticky_posts' => false,
'post__not_in' => array(get_the_ID())
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// HTML template
endwhile;
endif;
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment