Skip Navigation

[Resolved] Sort not working properly anymore

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

Problem:

Sort view's result by custom numeric field.

Solution:

You can setup the sort setting of view, for example:

https://toolset.com/forums/topic/sort-not-working-properly-anymore/#post-1233664

Relevant Documentation:

This support ticket is created 5 years 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 6 replies, has 3 voices.

Last updated by Armando 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1232555

I am trying to:
List posts that have a value from a custom field first, then the rest. I used solution here:
https://toolset.com/forums/topic/i-need-to-display-the-featured-businesses-first-or-at-the-top-of-the-list/

Link to a page where the issue can be seen:
hidden link

I expected to see:
All posts with value 1 first followed by the rest.

This solution initially worked, I tested it quite a few times posting from back end and through my CRED form. I updated Views plugin and came back a few days later and now the sort order is not working properly.

I have a custom field with a numeric value:
Custom Field: Premium
Default Value: 2

In the sort order I have:
Order By: Field - Premium
Secondary Sorting: Post Date

I used to get before the update (values):
1, 1, 1, 2, 2, 2, 2, 2, etc

Now I get:
2, 2, 1, 1, 1, 2, 2, 2, 2, etc.

Thank you!!

#1232671

Is there a chance you can send me a copy of this site where we can confirm that reverting to the older Views version solves this issue?
Then it should be relatively fast for us determining the problem.

I could maximally think of an issue in the Views settings > Order by where you'd have to set "order as numeric" when ordering by a number, as otherwise the WordPress query returns gibberish on numbers since interpreted as strings natively.

#1233197

Hello,

Thanks for the details, I am downloading the files, will update here if there is anything found.

#1233201
step-4.JPG

I have tried to import the your Backupbuddy file in my localhost, it does work, it stops in Step 4: Restoring Database, see screenshot step-4.JPG.

I suggest you try these:

1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, deactivate all Custom code snippets, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1233659

Thanks for the details, I am downloading the files, will update here if there is anything found

#1233664
Job-Listing.JPG

Here are what I found:
1) Please check the post view "Job Listing"
hidden link
in section "Ordering", you are using option Order by "Field - Premium" Descending
So it is expected result:
2, 2, 1, 1 etc.

2) I have tried to edit above post view, in section "Loop item in Test One ", add the field shortcode:
[types field='premium-number' format='FIELD_NAME: FIELD_VALUE'][/types]

Test it in front-end: hidden link
It works fine, see screenshot: Job-Listing.JPG

In your case, I suggest you setup the high "Jobs" posts with "Premium" field value: 2
lower "Jobs" posts with with "Premium" field value: 1

#1233980

My issue is resolved now. Thank you!

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