문제

I want to filter the posts list in admin area by custom field key/value : So, I do :

add_filter( 'pre_get_posts', 'my_admin_posts_filter' );
function my_admin_posts_filter( $query )
{
   global $pagenow;
   $metaquery = array(
        'relation' => 'AND',
        array(
                'key' => 'categorie_de_produit',
                'value' => array(23559),
                'compare' => 'IN'
        ));
    set_query_var( 'meta_query', $metaquery );
    //idem : $query->set( 'meta_query', $metaquery );
}

when the value exist, the results are ok. I have 3 results and the search form is visible:

enter image description here

But if the value (ex : 'value' => array(54644848486486486) ) doesn’t exist, the results are also correct (no result but it’s normal) but the search form is not visible…

enter image description here

Why the search form disappears?

도움이 되었습니까?

해결책

It's default of Wordpress, if there have no post, it's will hide search form.

LOGIC = If doesn't have any post, what want search? :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top