Sortable columns : Order by a treatment ?
-
Hi,
I’m currently developping a custom wordpress theme for a company which organize used cars sales.
I’ve created some sortable columns in the admin edit panel, for a custom post-type that I named “Vehicle”, in order to show the date of sell and the date of purchase for each vehicle. Thoses data come from two ACF date fields. I made both columns sortable with the manage_edit-{post-type}_sortable_column function and the pre_get_posts action.
Until there, no problem. All is working fine. But for the next stape, I’m technically stucked : I’ve created a third column, which calculate the difference between the two dates, in order to show the “stock duration” of the vehicle (in days). So I got a column which show results like “0 day”, “1 day”, “13 days”… (screenshot here, I translated it with the red labels).
However the pre_get_posts action waits for a query.
I wonder how could I make this “Stock Duration” column sortable, considering this one isn’t a meta_key, it’s a result coming from a specific treatment : the difference between two dates and a word “day” (or “days”) after it.
Is there a solution to simply order them by this kind of treatment ?
Thank you in advance.
- The topic ‘Sortable columns : Order by a treatment ?’ is closed to new replies.