Hello! I want to sort search results by the value of custom field ('name-official') for all posts (is this field filled or not).
But when I add filter in function.php like
function searchExcludePages($query) { if ($query->is_search) { $query->set('orderby','meta_value'); $query->set('meta_key','name-official'); $query->set('order','ASC'); } retu $query;
}
add_filter('pre_get_posts','searchExcludePages');
i've received results with filled 'name-official' only. What should i do to get results with non-filled field too?