php – How to sort custom sortable column by custom table value

Question

I have a custom table with data in it that I am showing in a column. I would like to make this column sortable.

Lets say that the custom table has three values for the sake of simplicity.

row_id, post_id, value

Where, post_id is the id of a post somwhere on the site.

Now in that post types custom column I show the value of the new table, and I would like to sort the the column by that value.

The way I have been trying to do it is to do a LEFT OUTER JOIN on the ‘join’ of the WP_query. (I have tried on pre_get_posts action and the post_clauses action.)

However I have been stuck on this problem for quite a while.

How would you go about sorting the column by the data found in this custom table? (Without resorting to meta values)

Let me know if that makes sense.

Thanks.

0
BlenderTutorials.org 2 weeks 2023-01-25T19:58:16-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse