Custom display method requires you to do 2 things:
- Attach Search & Filter to a query
- Enter the results URL where the query/results will be found
Attaching S&F to a query is easy enough, there are 4 ways to do this:
WP_Query
If using WP_Query then all you need to do is pass in the ID,:
$args = array('post_type' => 'post'); $args['search_filter_id'] = 123; $query = new WP_Query($args);
query_posts
If you prefer to use a more standard template (such as one from your theme) then you might want to use query_posts, again pass in the arguments to $args
or alternatively you can run our action which makes things a bit easier:
do_action("search_filter_query_posts", 123);
pre_get_posts
You can even attach S&F to a query when in the WP filter – pre_get_posts.
To do this, just call set
on the query, and again, set S&F ID:
function pre_get_posts_function($query) { //this would be a pre_get_posts you already have in place somewhere //then set `search_filter_id` $query->set("search_filter_id", 123); } add_action( 'pre_get_posts', array($this, 'pre_get_posts_function') );
Filter Next Query Shortcode
If you prefer not to modify templates, and you have access to the add the query in your page content (like in a page builder) then you can add our shortcode directly before:
[searchandfilter id="123456" action="filter_next_query"]
This should be placed directly before the element (as close as possible) that display your list of posts or results.