Skip to content

Instantly share code, notes, and snippets.

@bepatrickdavid
Created November 26, 2019 09:16
Show Gist options
  • Save bepatrickdavid/c60a25fdd7596f10623991a56b4dd8b4 to your computer and use it in GitHub Desktop.
Save bepatrickdavid/c60a25fdd7596f10623991a56b4dd8b4 to your computer and use it in GitHub Desktop.
WP: [Query] exclude latest post from the wordpress post loop with pagination
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 8,
'paged' => $paged,
'post__not_in' => array($idPostToExlude) );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
//do some stuff
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment