Skip Navigation

[Resolved] how to order a view by a specific field orde

This support ticket is created 7 years, 5 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 18 replies, has 2 voices.

Last updated by Christian Cox 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#529529

Is your site available online? I would like to take a look inside your wp-admin area to see why this isn't working as expected. If I need to make any changes, I will create a clone of your site using the Duplicator plugin, so I can install your site locally and make changes here. If that's okay with you, please provide login credentials in the private reply fields here. I will take a closer look.

#531520

Oh I see, this is a bit of a limitation with WordPress that I should have mentioned. When you sort based on some value, if the value does not exist for a result then the result does not get included in search results. I think the best way to handle this is to assign a placeholder value to post-place for those items instead of an empty value. That placeholder can be "*" if you want them to appear before ordered search results, or "Z" if you want them to appear after ordered search results.

#531522

bsd

I thought about that - and tried to make a default value to the post place field as 99999999 to be sure it will be after the ordered posts.
I do not undertand why you wrote to use a s tring field if we are talking about a number field.
But we have already about 400 posts - do we have to full them manually one by one?
Thanks

#531534

But we have already about 400 posts - do we have to full them manually one by one?
There are several options you can try to help automate this:
- Create a CSV file that includes the defaults and import these values into your postmeta table. More information about importing data can be found here: https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/

- Write a custom PHP script that adds the appropriate post meta values using WordPress add_post_meta. Run the script on your server, then remove it from your server. More information about this can be found here: https://codex.wordpress.org/Function_Reference/add_post_meta

- Write a custom SQL script that inserts values into your postmeta table automatically. Use phpMyAdmin or another SQL interface to run this script on your database. More information about that can be found in the MySQL documentation: hidden link