Created
April 30, 2024 19:10
-
-
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)
This file contains 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 | |
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