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

Returning a custom content types with meta values

I think I am understanding your correctly…If I’m way off, let me know!

// Assuming ideas is an array and you are looking for ideas=>two
$query = new WP_Query(
    array(
        // You can pass 'any' to post_type, but you get a hold of revisions, attachments, and menu_items. But I am not sure how many Custom Post Types you have ¯\_(ツ)_/¯ 
        'post_type' => array('cpt_one', 'cpt_two', 'cpt_three', 'etc'),
        'meta_query' => array(
            array(
                'key' => 'ideas',
                'value' => array('one', 'two', 'three'),
                'compare' => 'IN'
            )
        )
    )
);

// ideas is still an array here, and the value of 'two' lives inside of that ideas array() 
$query = new WP_Query(
    array(
        'post_type' => array('cpt_one', 'cpt_two', 'cpt_three', 'etc'),
        'meta_query' => array(
            array(
                'key' => 'ideas',
                'value' => 'two',
                'compare' => 'LIKE' // Less-known and not explained well in the docs.
            )
        )
    )
);

Going back to Jacob Peattie’s point, querying can be heavy at times depending on the complexity of your arrays. Again, if I am off here….let me know!

Related Posts:

  1. WordPress Orderby Numeric Value Not Working
  2. Linking posts together with Advanced Custom Fields “both ways”
  3. Query all posts where a meta key does not exist
  4. Meta query with boolean true/false value
  5. Get post with multiple meta keys and value
  6. How to use a custom post type as front page?
  7. Custom Queries: Joining On Meta Values From Two Custom Post Types
  8. How Do I Use WP_Query to Run This Database Query as Search Result?
  9. Querying Posts by Taxonomy From Alternate Network Site
  10. Query by 2 values of a repeater ACF field
  11. Can’t sort order of wp_query with 2 meta keys
  12. Comparing timestamps in meta query doesn’t work
  13. Display two post types ordered by two custom fields
  14. Query for posts from any post type but only add instock products
  15. Include both default and Custom Post Type in query modified inside pre_get_posts
  16. Automatically adding meta data to posts or multiple query help
  17. Having trouble with custom date field for CPT query (WordPress)
  18. WP_Query search posts by custom post type and custom taxonomy
  19. Calculating Bayesian average for custom post type
  20. Conditional to modify query results
  21. Is it possible to create a shortcode that will query a post based on taxonomies?
  22. Querying Term Posts in Loop
  23. Use get_post_types to query only custom posts types
  24. orderby in custom WP Query does not work
  25. Display custom post type from dynamic custom field
  26. convert custom query to wp_query
  27. Search / Filter posts on Title/Content OR Tags
  28. creat filter with wp_query
  29. WordPress request fiter order by related post’s post_title
  30. First custom field value (out of several) displayed twice after query
  31. Prioritize posts in query by meta keys?
  32. WP_Query orderby and tax_query
  33. Different Ways to Query Custom Post Types?
  34. Showing specific post in order of array wp_query
  35. WP_Query() with custom post type and taxonomy — get all terms?
  36. Displaying a div from an assigned meta_value when on a page
  37. How to get specific post meta by title or id
  38. $post->post_meta not pulling any post in wordpress/php
  39. WP_Query of custom post type sorted by meta_key has unexpected results
  40. is_main_query() never called on WP 4.4
  41. Create query for both custom post type and category
  42. WP_Meta_Query object with conditionals
  43. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  44. Query custom posts from custom taxonomy
  45. Is there a (preferable built-in) way to check what custom queries are used in a theme?
  46. Change search query in wordpress custom post type
  47. After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
  48. WP Query from two Custom Post type fields as statement
  49. WP Query: If field X is empty, show posts based on field Y
  50. Use WP_query to match post types based on custom field values
  51. How select query is generated in a Custom Post Type?
  52. How to sort by multiple values in a nested WP_Query
  53. WP_Query for custom taxonomies showing posts from non-specified terms?
  54. Custom meta fields not showing up in WP_Response Object via custom endpoint
  55. How to get post by meta value
  56. WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
  57. How do I get all authors posts of a custom post type outside loop
  58. post type => ‘any’ not applied my custom queries
  59. How to get Current week and current date record wp query
  60. How to get post meta for custom post type and taxonomy
  61. get_post_meta for Custom Post Type ( CPT )
  62. Get posts of an specific term of a custom taxonomy
  63. Conditional posts in WP_query for search
  64. Query Pulling the same post twice
  65. Is it possible to add query parameters on the archive page?
  66. meta query always fails even if data is correct
  67. WordPress custom post type
  68. Custom Post Type meta oembed html output resulting in WSoD
  69. Values inside a custom field to determine which category posts to display
  70. Query child posts on parents single.php?
  71. Query Posts From Multiple Post Types
  72. WordPress can only query up to 766
  73. Retrieve post data via WPDB class
  74. Querying meta values within an array
  75. Filter Custom post type by another Custom post type
  76. Create a list of months based posts
  77. Load posts via AJAX without draft status
  78. Query Multiple Post Types and Paginate Newly Created List
  79. Quering a post object based on another related post object
  80. updating one custom meta field only
  81. How to fetch posts that are stored in the different table than (default) wp_posts?
  82. WP_Query of a custom post type isn’t working
  83. WP_Query order custom post type with certain meta key value by post modified date
  84. Cant’ Display Custom Post Type Title Base on Tax Terms
  85. wp_dropdown_pages with tax_query clause
  86. Cache issue with WP_Query and custom field filtering
  87. Post Type => Any conundrum
  88. Add a class to post_class if more than one post shares same meta_value_num
  89. Custom Post type showing up in loop, regular posts are not showing up
  90. All in one calendar custom post type query doesnt work as expected
  91. filter the_content, custom post type, and wp_query
  92. Loop for custom-post-type comparing taxonomy terms for “related” posts?
  93. Displaying Portfolio Filter by Category Order (alphabetically)
  94. Function to return values from metabox
  95. WP_Query meta compare must include ALL array values
  96. Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
  97. Add a meta field to the list of results for a custom post type
  98. best way to use custom taxonomy, post type and meta in a job system
  99. Query Custom Post Type by Taxonomy
  100. Empty meta-box returns publishdate if no value is set?
Categories custom-post-types Tags custom-post-types, post-meta, query, wp-query
Twin value tags as an esoteric taxonomy
Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?

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