Hope this code may work for you.
$query1 = new WP_Query( array(
'post_type' => 'product',
's' => $searchStr
));
$query2 = new WP_Query( array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'my_meta_key',
'value' => $searchStr,
'compare' => 'LIKE'
)
)
));
$result = new WP_Query();
$result->posts = array_unique( array_merge( $query1->posts, $query2->posts ), SORT_REGULAR );
$result->post_count = count( $result->posts );
Related Posts:
- Use REGEXP in WP_Query meta_query key
- WP_Query orderby one custom field then another in one query
- Pagination on a WP_query not showing navigation links
- switch_to_blog() performance considerations & alternatives
- Is it possible to select against a post’s parent’s fields with WP_Query?
- What’s the best approach for showing posts by A->Z order?
- Load more AJAX on WP Query
- page was loaded over HTTPS, but requested an insecure image
- WP_Query: How do I sort on meta value and use LEFT JOIN?
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to search by title or tags exclusively?
- Paginated pages are showing correct content but pagination links are not
- Query Posts but only return 1 from a custom taxonomy?
- Loop inside the loop
- WordPress search exact match
- How to count post type that has a particular term?
- Group posts by meta_key
- What is the difference between RELATION “AND” and “OR” in TAX_QUERY?
- Query Set Order By Author
- ‘&’ causes an error in my shortcode when I list the content of the page
- wp_query, give first post different formatting
- Best practice custom function, where to echo the variables?
- meta_query works locally but not on live server
- getting posts and number by specific meta value in multiple meta
- How can I pick a single post from the latest 3?
- Retrieving list of a custom post type in a widget without using WP_Query?
- How to orderby meta_value_num with dollar ($) sign
- Order WP_Query by multiple fields, subtracting them from one another
- How can I convert results of WP_Query (of Custom Post Type, with Custom Fields) to JavaScript?
- Query with custom taxonomy not working
- How to order posts in wp_query by the user role (2 roles in array)
- Is there a way to include a post multiple times in the same query result?
- showing all search result in one template
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- How can I filter by slug depending on language selection
- WP Query Args – Title or Taxonomy Value
- Ajax WP_Query reutrns no results on author.php
- Large AND OR query timing out
- WP_query wp_posts_counts returns only count of admin and not users
- Categorising search results based on Custom Fields
- How to query for all posts that have a particular meta key?
- Custom taxonomy.php not working
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- Advanced WP_Query with meta_query, orderby?
- WP_Query calls all posts?
- WP_Query Taxonomy categories filtering
- The best way to store variable across different widgets
- Assign a minimum result count for WooCommerce query shortcodes?
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- WPQuery calling specific posts problem
- Retrieve data from wordpress db via input and put those result in dropdown
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- Filtering by multiple conditions in the loop
- Limit loop to future events
- How to access $wp_query object from array of posts given by get_posts?
- Echo User Name from User with most comments of today?
- Custom wp_query differs on index page and category page
- WordPress Queries Not Working?
- Links in the_content not linked
- how do I write this wp_query select statement?
- How to make a post with certain taxonomy term display first before other post with only one query?
- Exception for excluding previously displayed posts in queries
- Post incorrectly excluded when using “category__in”?
- How to search by slug and old slug in single API
- How do I compare the value of two taxonomies in a wp_query
- query hook parse_tax_query function takes no effect
- Categories In English version showing not canonical URL, instead shows query search result
- Multiple meta_query not returning rows
- Related posts queries
- Check for not NULL not working in meta query
- What code to use in an array to call the current sub-category?
- Display hierarchical structure of Custom post type in UL LI
- Pagination for Category does not work
- Query against multiple locations within single custom post type post
- Order by meta date with a thousanth of a second defaults to post order
- How to debug none working search query?
- ACF query-pass field value
- How to make a search query if not found in post table then search in postmeta table?
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- how to show more than 1 post into three columns query
- Show All with Isotope
- tax_query not working for taxonomy slug
- Problem with infinite scroll on multisite with custom query
- active link for most recent post on vertical tabs
- How to Insert data with wp cron
- Get X posts for all post types on Taxonomy term archive
- How to list posts of a given format
- option select form always deleting the sql query
- Page displaying 1st post from a range of custom tax?
- WP Query Bug? Cannot find out why posts are not found!
- get contents and permalink from a specified page
- What query to append the 10 next posts?
- How ‘secure’ are loops?
- What triggers these wordpress queries on my homepage?
- How to do a loop inside a loop?
- Pagination not working in secondary query
- Search query alteration not working for meta values
- WP_query shortcode inside acf Repeater breaks the repeater loop