Skip to content

Instantly share code, notes, and snippets.

@ihslimn
Created April 30, 2024 19:10
Show Gist options
  • Save ihslimn/ef89c9d2927099fa56af00e64de9b313 to your computer and use it in GitHub Desktop.
Save ihslimn/ef89c9d2927099fa56af00e64de9b313 to your computer and use it in GitHub Desktop.
JetEngine Query correct per page for Sticky Posts (not guaranteed to work with pagination)
<?php
add_filter( 'jet-engine/query-builder/query/items', function( $items, $query ) {
if ( false !== strpos( $query->name, '--sticky-correct' ) ) {
$per_page = ! empty( $query->final_query['posts_per_page'] ) ? $query->final_query['posts_per_page'] : 10;
$items = array_slice( $items, 0, $per_page );
}
return $items;
}, 0, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment