I have a custom post type namely portfolio, I need to be able to sort this by meta value which is the authors name ::: I’ve bee trying several examples but none work ::: Any help would be appreciated :::
My Code
$args = array(
"post_type" => "portfolio",
"meta_key" => "authors_name",
"orderby" => "meta_value",
"order" => "ASC"
);
$custom_query = new WP_Query( $args );
This Also Does Not Work
$args = array(
"post_type" => "portfolio",
"meta_key" => "authors_name",
'meta_query' => array(
array(
'key' => 'authors_name',
),
),
'orderby' => 'meta_value',
'order' => 'ASC',
);
I was able to sort this issue with add_filter(‘pre_get_posts’ ::: In essence this is what my script now looks like :::