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:
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â¦
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? 🙂