Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

meta post search

You have a typo in your $advtxtQuery query– $where =" (( post_typs LIKE 'projects')...

For the rest, both queries are searching on the same key so use IN instead of trying to create two separate arrays, as in the Codex example below:

 $args = array(
   'post_type' => 'my_custom_post_type',
   'meta_key' => 'age',
   'orderby' => 'meta_value_num',
   'order' => 'ASC',
   'meta_query' => array(
       array(
           'key' => 'age',
           'value' => array(3, 4),
           'compare' => 'IN',
       )
   )
 );
 $query = new WP_Query($args);

You could just pass your $category as is but I’d filter it for maliciousness. In fact, your values are (or seem to be) static so the safest thing is to do this:

$category_args = array();
if(!empty($category[0])) $category_args[] = "Planet";
if(!empty($category[1])) $category_args[] = "People";

And pass that into your query like so:

if( !empty($category_args) ){
  if(!isset($argsearch["meta_query"])){
      $argsearch["meta_query"] = array();
  }
  $argsearch["meta_query"][] = array(
      'key' => '_cmb_project_category',
      'value' => $category_args,
      'compare' => 'IN'
  );
}

Related Posts:

  1. How to make search include data from wp_postmeta?
  2. Searching by meta values showing inappropriate result
  3. How to make search include data from wp_postmeta?
  4. Modifying post content with the_post action hook
  5. How to query two meta fields and display results between them
  6. search for single meta_key with numeric array of meta values
  7. meta field search too restrictive in pre_get_post() for custom search
  8. Consistent and Admissible Heuristics
  9. Solr vs. ElasticSearch
  10. How do you make Vim unhighlight what you searched for?
  11. grep for special characters in Unix
  12. Search is always exact [closed]
  13. Advanced search form with filters for custom taxonomies and custom fields
  14. how to limit search to post titles?
  15. How to create live autofill search?
  16. How can I implement a location based (zip code) search in WordPress?
  17. How to highlight search terms without plugin
  18. How do I remove Pages from search?
  19. Empty search returns home page, how to return not found search page?
  20. How to search for (partial match) display names of WordPress users?
  21. How does WordPress search work behind the scenes?
  22. Remove some pages from search
  23. Limit search to latin characters
  24. How to look at code in WordPress repositories without downloading?
  25. Extend WordPress search to include user search
  26. Display search results within the same page
  27. Empty search input returns all posts
  28. How can i move search results onto a specific page?
  29. Remove meta robots tag from wp_head
  30. WordPress blog with 30 000 posts: poor search performance
  31. Template issues getting ajax search results
  32. WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
  33. Insert DIV container below 1st search result
  34. Unified search across separate WordPress installations
  35. Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
  36. How to make WordPress search prioritise page titles?
  37. How to add the author search in the default wordpress search?
  38. Admin Area Custom Type Search By Meta Fields Without Title & Content
  39. How do I filter the search results order?
  40. How to insert a span inside a search form?
  41. How do I redirect /search/ to wordpress search template?
  42. How do I Paginate Search Results for Custom Post Types?
  43. Dealing with Many Meta Values, 30+
  44. How to search for users based on added user metadata
  45. Search by Post ID and display content of the post in search result
  46. Extending search query with additional $sentence value
  47. Link to search page without search parameter
  48. Search/Replace for editor in HTML-mode
  49. How do I search events between two set dates inside WP?
  50. Search only blog posts (default WP search widget)
  51. Exclude pages from WordPress search result page
  52. How to pass a search $_GET parameter to a new custom search page?
  53. Do I need to sanitize WordPress search query?
  54. Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
  55. Search Using Post ID
  56. Search custom post type by meta data
  57. Neither the_excerpt() nor the_content() works properly?
  58. Let user change posts per page
  59. WP User Query with search columns and meta query
  60. Exclude top-level pages from search results
  61. WordPress 3.6, searchform.php problems
  62. Search in non-English language returns only one result
  63. Complex Search functionality. Advice needed
  64. Get user role by using user_id in buddypress
  65. How to use next_post_link and previous_post_link on single posts in search results
  66. Why is there a class=”screen-reader-text” on my search button?
  67. template_include for search.php makes WordPress think its on the home page
  68. Turning Broken URLs Into Search Terms?
  69. How can I implement faceted search with WordPress 3.x?
  70. can’t limit search to only pages
  71. Add custom parameters to JSON API search query?
  72. Combining Meta_Query key values for one array
  73. Change the Search Base in a multi language wordpress
  74. Display posts from an author using search parameters (not author template/query_posts)
  75. Search everything (posts, pages, tags, cpt, meta)
  76. Search: Only One Result Returned
  77. Include custom table into search results
  78. How to redirect search result page to post
  79. Create multiple Search functions for posts / custom post types and everything
  80. How Do I Use WP_Query to Run This Database Query as Search Result?
  81. WordPress Admin Panel search posts with custom post meta values along with title
  82. How to stop _wpnonce and _wp_http_referer from appearing in URL
  83. Return all Tags from search results
  84. How to exclude post body from WP search
  85. Custom Permalinks Break Search Pagination
  86. Search results with custom loop don’t update when paged
  87. ElasticPress Indexing multiple sites
  88. Search uses index.php instead of search.php on renaming search field from “s”
  89. How to search through pdf media files?
  90. Search outside of the “loop”
  91. Replace URL with Site Title in Search Results
  92. How do I change WP search results order?
  93. Include Author profile in search results
  94. Force WP to use a certain search template
  95. Set minimum number of characters in the search
  96. search.php template not loading results
  97. Adding arg to search results page
  98. search only pages if on page
  99. Search results URL without query string variables
  100. How can I include meta box content when searching?
Categories search Tags post-meta, search
advanced paging in wordpress
Lead form that submits to 2 external APIs

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress