Skip Navigation

[Resolved] Custom Search in Classic Views: Default frontend sort option?

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 2 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2473403

a.R

Hi 🙂

How can we set that default sort option?
Unfortunately, the video tutorial is only about blocks and the code is not shown there.
https://toolset.com/course-lesson/creating-a-custom-search/#add-front-end-sorting-to-search-results

#2473533

a.R

... and how choose sorting option and direction by URL-parameter?

#2473815

Hello,

Q1) How can we set that default sort option?
I assume you are using Blocks editor to setup the post view, you can find and select the "Sorting control" block, in the block setting panel, section "Default order", choose the default sort settings, see my screenshot default-order.jpg

Q2) how choose sorting option and direction by URL-parameter?
You can test it in frontend, try to change the resort the results, you will get the required URL parameters, for example:
hidden link

#2473857

a.R

Ok, thank you, Luo Yang.
However, as I have mentioned, we are using the classicviews plugin, NOT blocks.
How set default sort options there?

Thank you 🙂

#2473883
Ordering.jpg

For the classic post view, the default sort options is in section "Ordering", see my screenshot Ordering.jpg
For the frontend sort control shortcode, the first option is the default value, you can setup the first value same as the "Ordering" setting, for example:

[wpv-sort-orderby type="select" options="post_date,post_title" label_for_post_date="Post date" label_for_post_title="Post title" ...][/wpv-filter-controls]

Above shortcode is using default value "post_date".

#2473915

a.R

What do those URL-parameters mean? Is there a documentation for this?

What´s the difference btw wpv_sort_orderby and wpv_orderby ?
What are the options for wpv_sort_orderby_as ?

#2473923

a.R

... does type="radio" work flawlessly?

#2474103

There isn't difference between wpv_sort_orderby and wpv_orderby(compatible for old version of Toolset plugins) URL parameters, you need to pass the same value to both URL parameter meters.

The "wpv_sort_orderby_as" is for sort type, for example:
- String
- Number

And yes, type="radio" should work flawlessly.

#2474303

a.R

Ok, thank you...

... and what is the right wpv_sort_orderby_as for dates?

#2474409

For custom date fields, you can pass value "numeric" to URL parameter wpv_sort_orderby_as, for example:
wpv_sort_orderby_as=numeric