Varro on "Order queries by meta_value even if meta_key is not filled"

خرید بک لینک

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?

WordPress ...

ما را در سایت WordPress دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 269 تاريخ: جمعه 1 مرداد 1395 ساعت: 13:42

صفحه بندی