Skip Navigation

[Resolved] Order by multiple custom fields in more than one view.

This thread is resolved. Here is a description of the problem and solution.

Problem:
Order by multiple custom fields in more than one view.

Solution:
The user was using the duplicate function name. The function name for hook you should use should be unique.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/order-by-multiple-custom-fields-in-more-than-one-view/#post-2126269

Relevant Documentation:

This support ticket is created 3 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by rudolphv 3 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2126219
Snippet.jpg
Fatal error.jpg

Tell us what you are trying to do? I have successfully adapted the code from the link under 'documentation followed' to set up a sort in a view on two custom fields (Dating and Artist) and put this in a custom code snippet under Toolset Settings. See screenshot.

But I now want to use this for other views, like sort a similar view on Artist and Dating. When I try to add a second snippet with the adapted code I get a fatal error when I start up the site, see screenshot. Individually the two snippets work fine, but when I both activate them : Fatal error!)

Any suggestions on how I can get this type of sort to work for multiple views ?? Apologies, I am not a programmer (so Toolset is great for me) but in this instance, I need a functionality (sort on multiple custom fields for multiple views) that alas is not yet a standard option in Toolset. I have tried to add the code for the second view (between second set of {} ) in the first snippet but,,,no joy:(

Is there any documentation that you are following? https://toolset.com/forums/topic/how-to-apply-custom-code-to-order-view-by-multiple-custom-fields/#post-920846

Is there a similar example that we can see? hidden link were I ordered on Dating and Artist

What is the link to your site? hidden link

#2126269

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

If you copy paste the code second time, you need to change the function name "tssupp_modify_orderby" to "tssupp_modify_orderby1" or any other name with function name and add_filter() hook.

#2126583

My issue is resolved now. Thank you!