Hot answers tagged

3

You may need to include a tax_query for the Woocommerce taxonomy (called 'product_cat'): $tax_query = array( array( 'taxonomy' => 'product_cat' ), ); $query->set( 'tax_query', $tax_query ); } return $query; } However, you'll have to ensure that you can return posts AND pages AND product categories and also ...


2

Wordpress also provide more filter to can change wp query using filters. What i need logical to use filter to override query below sample of code if this helpful for you. add_filter( 'posts_where', 'posts_where_condition_search' ); $wp_query = new WP_Query( array( 'post_type' => 'press-release', 'posts_per_page' => ...


1

The WP_Query class can match IDs as well as search terms. An idea would be to use the pre_get_posts action to detect if the search term is numeric and, if it is, set the query to work with attachments while passing the search as the ID. function wpse223307_allow_search_by_attachment_id( $query ) { //Only alter the query if we are in a search screen,... ...



Only top voted, non community-wiki answers of a minimum length are eligible