Forums › Forums › Search & Filter Pro › Changing the Deafult order
Tagged: default order
- This topic has 9 replies, 2 voices, and was last updated 5 years, 8 months ago by Trevor.
-
Anonymous(Private) April 3, 2019 at 12:11 pm #207342
Im tryin to change the order of my custom post archives to a custom order. I followed many wp manuals, but nothing seems to work.
Then I realize that S&F is probally overiding the orderby function of the archives where the filter is added.
Where and how can I change the default order of S&F?
The deafult is date i think. The custom order is not a meta value and it isalso not listed in > S&F> Posts > Default Order:
Thanks
Anonymous(Private) April 3, 2019 at 3:08 pm #207366I want the archive to sort on ‘orderby’ => ‘post_views’. Based on this plugin: https://dfactory.eu/products/post-views-counter/
Thanks!
Anonymous(Private) April 3, 2019 at 4:05 pm #207391No it does not stores a post meta or meta_key value. That is the other method some people use for sorting post views without a plugin using meta etc
This plugin does creates a table wp_post_views though.
But we used it on our old site. Like this:
$query = new WP_Query(array(‘post_type’ => ‘download’, ‘orderby’ => ‘post_views’, ‘order’ => ‘DESC’));This simply will sort the default archive on most view posts.
But on this page it is not working
https://www.dl-sounds.com/member/downloadsThe downloads are sorted by date. No matter what we tried.
Trevor(Private) April 3, 2019 at 4:23 pm #207393Ah. Then the only way to do this is to edit the query arguments passed to our plugin. Use this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
And make sure no sort order is actually set in our plugin.
Anonymous(Private) April 4, 2019 at 1:00 pm #207512Ok,
I added the next code to function.php
function filter_function_name( $query_args, $sfid ) { //if search form ID = 225, the do something with this query if($sfid==6178) { //modify $query_args here before returning it $query_args['orderby'] = 'post_views'; } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_function_name', 10, 2 );
But now if I use the filter it is only showing 2 downloads:
https://www.dl-sounds.com/member/downloads/?sort_order=name+asc&_sfm_bpm=0+1000without the filter it is working:
https://www.dl-sounds.com/member/downloadsI must be doing something wrong?
Trevor(Private) April 4, 2019 at 1:13 pm #207516See this link:
https://www.dl-sounds.com/member/downloads/?sort_order=name+asc
The difference is that I removed the range values. This means that the other posts have no values for that range, and are thus excluded.
Anonymous(Private) April 5, 2019 at 8:15 am #207604It is more like it does not work with S&F order filter.
If I change the default order of the archive to post views instead of date, it is setting all S&F filters to post views. But this is not the case with the standard date setting.
Why is this? Should we code the core files of S&F? Is it possible to make it work then?
Because we need this ‘most popular’ setting. It is essential for CRO & marketing etc.
We need this for the time being.Trevor(Private) April 5, 2019 at 2:57 pm #207658In this URL:
https://www.dl-sounds.com/member/downloads/?sort_order=name+asc&_sfm_bpm=0+1000
you have sort by name enabled. Do you need sort by name AND by post count? Surely that would not work?
-
AuthorPosts