Skip Navigation

[Resolved] Can wpv-heading be sorted as a value?

This support ticket is created 5 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
- 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 8 replies, has 2 voices.

Last updated by Edward Barker 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1173079

Following on from the resolution of my previous problem https://toolset.com/forums/topic/problems-trying-to-create-a-calculate-function/ I've reached my next stumbling block.

I'd like to create a view with sortable columns one of which I'd like to be "Commission Value". The problem I have is that potentially the column would be populated using two custom fields one based on commission percentage that is converted into a value, percentage-commission-value (see above thread) and one that is a fixed rate entered by the user, commission-fixed. Both equate to a commission fee that someone could potentially be paid so that's why I want them in the same column.

However from my understanding wpv-heading is limited to only sorting by one field which obviously doesn't work becuase a) when you do just have one field and then press sort you lose some of the results and b) even if all the results were still displayed they won't be displayed in numerical order which is kind of the point of the column.

Is there a way to sort a column by two fields at the same time or just by numerical value?

Many thanks as always, you guys rock!

Ed

#1173281

Hello,

Yes, it is expected result:
wpv-heading is limited to only sorting by one field

If you are going to sort the result by multiple custom field, please try Sorting Controls, see our document:
https://toolset.com/documentation/user-guides/allowing-visitors-to-sort-the-front-end-results/

Screenshot:
hidden link

#1173307

Yeah I thought of that but even if I use the sorting control it wont sort one entire column into value order if it is made up of two custom post types

#1173314

Is there a way to implement something like this instead ......

hidden link

#1173316

Please elaborate the new question with more details:
use the sorting control it wont sort one entire column into value order if it is made up of two custom post types

The "Sorting Controls" of Views plugin is able to sort the result by one or multiple custom fields in front-end, if there are posts from two post types, you just need to query posts of both post types, and make sure all posts have value in those sortby custom fields, since there is a limitation in WordPress class WP_Query:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
'meta_value' - Note that a 'meta_key=keyname' must also be present in the query

#1173330
Screenshot 2018-12-27 at 09.25.33.png
Screenshot 2018-12-27 at 09.25.56.png

The "sorting controls" uses a system of sort by custom field 1 and then by then by custom field 2 so it will end up looking like image 1.

What I want it to look like is image 2.

#1173340

Yes, you are right, I don't think it is possible to sort the result as your screenshot
hidden link

I suggest you add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

#1173342

No worries.

But is there a way to implement the suggested javascript from w3schools or something similar to it? I've tried to run the script inside the JS boxes when setting up the views but the loop editor and content template for the view don't seem to be talking to each other?

#1173440

Don't worry about it. For anyone else who has this issue please just apply the following Javascript library .....

hidden link

It works a charm.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.