I have 4 text field type in a custom post type, these are brand_fbn
,model_fbn
,year_fbn
and plate_number
. I want to sort the post, by brand_fbn
– model_fbn
– year_fbn
– plate_number
. But im stuck with that,
this is my code(error)
$ins = new WP_Query(array(
"post_type" => "application-list",
"author" => $current_user->ID,
"meta_key" => array("year_fbn","plate_number"),
"orderby" => "meta_value ",
"order" => "ASC"
));
I know this line wont work, "meta_key"=>array("year_fbn","plate_number"),
can someone help me. thanks
You’ll need to query for the meta fields so that they are
JOIN
ed withinWP_Query
and then use theposts_orderby
filter to order your results by those meta fields – the alias use will be in the formatmt1.meta_value
.