Sauter la navigation

[Résolu] Sort view by an ordered string of IDs

This support ticket is created Il y a 4 années et 6 mois. 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.

Ce sujet contient 1 réponse, a 1 voix.

Dernière mise à jour par umbertoZ Il y a 4 années et 6 mois.

Auteur
Publications
#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