Custom filter in admin post list makes search form unvisible

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:

Read More

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?

Related posts

Leave a Reply

1 comment