Hi everybody, I have a problem of search box

It must be in the included in the code somewhere. Most search forms will have a search.php or some other variation of that name if it is a custom search (located in the root of your theme). **EDIT: ** off the back of our short conversation below. You have used WooCommerce to arrange your products. … Read more

Issues with search after added meta_query

There is one problem with your query. You assume, that it will use OR relation to all query parts. But it won’t. The OR operator will be used only for meta_query parts. It means, that your query is looking for posts that are matching these criteria: (post_title LIKE query) AND ( ean LIKE query OR … Read more

Hide products in uncategorized category from search results

Try to add the following lines of code at the end of your theme’s functions.php file: function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘uncategorized’ ), ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ ); … Read more

Include future posts in tags and in search

To achieve the intended result you will have to modify the query by adding the future value to the post_status parameter via the pre_get_posts filter hook. add_action( ‘pre_get_posts’, ‘se338152_future_post_tag_and_search’ ); function se338152_future_post_tag_and_search( $query ) { // apply changes only for search and tag archive if ( ! ( $query->is_main_query() && (is_tag() || is_search()) ) ) … Read more

How to avoid bypass of search bar rules?

You want to use the pre_get_posts action to modify the search query on the server side. The pre_get_posts Codex have some examples to get you started. To target the main search query, try this: function my_search_filter( $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { // Use $query->set(); … Read more

Can’t find a product by SKU

Add This Code In functions.php then save it. After Changes, You can see the changes in the screenshots function search_by_sku_for_admin( $search, &$query_vars ) { global $wpdb, $pagenow; if ( ‘edit.php’ != $pagenow || empty($search) ) { return $search; } $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘product’, ‘meta_query’ => array( array( ‘key’ => ‘_sku’, … Read more