I want to order posts by title, but always show featured posts first. I have the code below to order posts by title. Now I would like to always show posts first that have the metafield 'wiloke_listgo_toggle_highlight' with the value '1'. How can I accomplish this?
/* Order Posts Alphabetically */
function prefix_modify_query_order( $query ) {
if ( is_main_query() ) {
$args = array( 'title' => 'ASC' );
$query->set( 'orderby', $args );
}
}
add_action( 'pre_get_posts', 'prefix_modify_query_order' );
orderby
to an array like that["meta_value" => "ASC", "title" => "ASC"]
and setmeta_key
to"wiloke_listgo_toggle_highlight"
.