Skip Navigation

[Resolved] wpv-sort-orderby – possible to setup a default option?

This support ticket is created 2 years, 9 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 2 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#2323307

a.R

Hi 🙂

Is it possible to setup a default option there when creating a custom search?

Thank you.

#2323367

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for getting in touch.

Yes there is. Are you using the classic view or was your view created with the block editor. Also is there a frontend sort filter on your site ?

Please let me know.
Thanks,
Shane

#2323771

a.R

This seems to be complicated?

classic view.

what do you mean with fsf?

#2324031

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2022-03-22 at 9.42.36 AM.png

Hello,

No it is not complicated because there is an order option on the view. If you go to your views edit page and scroll to "Ordering", you should be able to set the ordering option of your view here. See Screenshot.

Please let me know if this helps.
Thanks,
Shane

#2328171

a.R

Ah yes, that´s clear. Thank you.

BUT

I have a custom search that will be sorted first by rating and then by post date (second criteria)

But in the search form, users can choose to sort by rating or another field in the post.
That works quite smoothly, BUT:
When calling the search now, no sort criteria in the form is marked initially and I have to set the sorting by jquery, what results in some delay and confusion. So I would like to tell the search in that case how to sort results, maybe by url parameter?

SORRY for having been unclear.

#2328767

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for the clarity. The URL parameter can be used I believe and you're making reference to when the view has no search criteria correct?

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-154377

If you look here you can see that the view has an orderby parameter. What i'm not sure is if this can accept a shortcode, however you can try doing the following.


[wpv-view name='myview' orderby="[wpv-search-term param='my-url-param']" order="asc"]

Where myview is the slug of the view and my-url-param is the URL parameter of the view. This is where you can provide the custom field value in the URL prefixed by "field-" as per the documentation.

Thanks,
Shane