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 he
I was able to sort this issue with add_filter('pre_get_posts' ::: In essence this is what my script now looks like :::
function laudes_order( $wp_query ) {
$wp_query->set('meta_key', 'authors_name');
$wp_query->set('orderby', 'meta_value');
$wp_query->set('order', 'DESC');
}
add_filter('pre_get_posts', 'laudes_order');
$args = array(
"post_type" => "portfolio",
);
$custom_query = new WP_Query( $args );