Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active October 28, 2019 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/7b998e3966403b3f446f271d87268f1a to your computer and use it in GitHub Desktop.
Save djrmom/7b998e3966403b3f446f271d87268f1a to your computer and use it in GitHub Desktop.
facetwp change template query args by url
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment