Skip Navigation

[Resolved] Sort view by an ordered string of IDs

This support ticket is created 4 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.

This topic contains 1 reply, has 1 voice.

Last updated by umbertoZ 4 years ago.

Author
Posts
#1841817

Hi, I've CPT Books and CPT Stores. Eash store has a text custom field where I store a string of IDs of Books, like "345,65,2301,4".

I built a view where I filter books by the string of IDs, so I get only the books of the selected Store. My problem is that I'd like to sort the books in the loop just like they are ordered in my custom field string. So this should be the order of the items in my loop:

1 Book with ID 345
2 Book with ID 65
3 Book with ID 2301
4 Book with ID 4

Is there a way to do it? Can you give me some idea how to customize wpv_filter_query to sort items by the string order?

thanks

#1841825