facetwp custom offset for facetwp template

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/**
** use a custom offset for a facetwp template query
**/

add_filter( ‘facetwp_query_args’, function( $query_args, $class ) {
if ( ‘example’ == $class->ajax_params[‘template’] ) { // change example to name of your template
$offset = 5; // change 5 to the offset value needed
$per_page = ( isset( $query_args[‘posts_per_page’] ) ) ? $query_args[‘posts_per_page’] : get_option( ‘posts_per_page’ );
$paged = ( isset( $class->ajax_params[‘paged’] ) ) ? $class->ajax_params[‘paged’] : 1;
$offset = ( $paged – 1 ) * $per_page + $offset;
$query_args[‘offset’] = $offset;
}
return $query_args;
}, 10, 2 );
{{/gist}}