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
... and how choose sorting option and direction by URL-parameter?
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
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 🙂
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".
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 ?
... does type="radio" work flawlessly?
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.
Ok, thank you...
... and what is the right wpv_sort_orderby_as for dates?
For custom date fields, you can pass value "numeric" to URL parameter wpv_sort_orderby_as, for example:
wpv_sort_orderby_as=numeric