Product search not working in wp-admin
-
Hi!
Like the title says, I can’t use the search function in wp-admin. If I go to products and use filters, the filters work. However if I type anything in the search bar, INCLUDING page number, I get a notification that there are no products. Even if leave the search bar empty and just click Search, it says that there are no products.
I’m using the code below, however, if I have the code active, a lot of stuff doesn’t work properly anymore. For example, I can’t see the gallery to add images that were already uploaded, because it says that there are no pictures. It also messes up categories, and a bunch of other stuff (only in wp-admin). Even though these problems are only present in wp-admin, it’s very annoying that I have to add the /* and */ to the code so it’s disabled or enabled, depending of what I need at that moment.
The Code:
add_action( 'pre_get_posts', 'products_pre_get_posts' ); function products_pre_get_posts( $query ) { if(is_admin()){ $query->set( 'tax_query', array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => get_terms( array( 'taxonomy' => 'product_cat', 'fields' => 'ids' ) ) ) )); } }
Kind regards
The page I need help with: [log in to see the link]
- The topic ‘Product search not working in wp-admin’ is closed to new replies.