Created
June 30, 2018 16:05
-
-
Save adamlaki/62ce18e33619a5d39793daf2550aa6af to your computer and use it in GitHub Desktop.
Exclude Current Post from WP_Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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