facetwp change template query args by url

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** change the query args according to page. Page is always the without the domain and without starting and ending /
** demo/cars or something/something or my-page
**/

add_filter( ‘facetwp_query_args’, function( $query_args, $class ) {
if ( ‘my-page’ == FWP()->helper->get_uri() ) {
$query_args[‘post__in’] = [ 2 ];
} elseif ( ‘other-page’ == FWP()->helper->get_uri() ) {
$query_args[‘post__in’] = [ 2,3,7,9 ];
}
return $query_args;
}, 10, 2 );
{{/gist}}