Question

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?

Était-ce utile?

La solution

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? :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top