Hi,
I spent ages to figure out how to order my meta_query based on a meta key "Post" File Type.
I use "Post" File type to link a specific post to a CPT. But the value stored in the DB is the related post ID, and I want to order bye the related post title.
This is my code :
$query->set( 'meta_query',
array(
'commune_elu_order' => array(
'key' => 'commune_elu', // MB Post File Type
'compare' => 'EXISTS',
'type' => 'NUMERIC'
)
)
);
$query->set( 'orderby',
array(
'commune_elu_order' => 'ASC'
)
);
My result is ordered by "commune_elu_order" ASC as expected.
But I would like to Orderby the post_title returned by the Key (meta_value) 'commune_elu'.
The result is ordered by "meta_value" column from table "wp_postmeta"
Ex of a line I have in my DB:
meta_id = 41876
post_id = 1970
meta_key = commune_elu
meta_value = 1215
I would like to order by the post_title of the returned meta_value.
What will be your recommendation for this situation ?