Forums › Forums › Search & Filter Pro › Sorting the results
- This topic has 1 reply, 2 voices, and was last updated 5 years ago by
Trevor.
-
Anonymous(Private) April 9, 2020 at 11:01 am #239522
Hi Trevor,
We have gone live now with our site that uses the Search & Filter Pro as follows:
We have a general search at the top that looks under Our People, Insights and Pages and displays the results in tabs as per this example:
https://www.brachers.co.uk/?sfid=8450&_sf_s=commercial
We did this by using:
<?php
// WP_Query arguments
$args = array (
‘post_type’ => array( ‘insight, member, page’ ),
‘posts_per_page’ => ‘-1’,
);
$args[‘search_filter_id’] = 8450;// The Query
$query = new WP_Query( $args ); ?>and then outputting the different parts of the array like this:
<?php while ($query->have_posts()) { $query->the_post(); if (get_post_type() == ‘page’ ) : ?>
<?php while ($query->have_posts()) { $query->the_post(); if (get_post_type() == ‘member’ ) : ?>
etc.
In the actual plugin, under Settings and Defaults we have selected Default Order: Type (post type) and a
Secondary Sort Order: of Date (ASC).This gives us the correct data and for the most part sorts the pages and Our People in alphabetical order which is what we want. It doesn’t work well on the Insights area though as it then sorts them in oldest date first order.
Is there a way we can have the Insights bit sort in a different way to the other two (Pages and Our People)?
Thanks
Trevor(Private) April 9, 2020 at 11:06 am #239525You might be able to set a complex sort order (orderby) using this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
You may need to consult a third party coder on how you might go about this.
-
AuthorPosts