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

Is it possible to retrieve all posts with a certain value for metadata?

I am assuming your custom post type is also “series”.
Can you try this, it should work.

 $args = [
        'post_type' => 'series',
        'posts_per_page' => -1,
        'meta_query' => [
            [
            'key' => 'series',
            'value' => 19,
            'compare' => '=',
            'type'=>'NUMERIC'
            ]
        ],
    ];

    $posts = new WP_Query( $args );

or you can simple use:

$args = [
            'post_type' => 'series',
            'posts_per_page' => -1,
            'meta_key'=>'series',
            'meta_value'=>19,
            'meta_compare'=>'=',
            'meta_type'=>'NUMERIC'
        ];

        $posts = new WP_Query( $args );

If you are using these meta values as NUMERIC it will be essential to provide “meta_type”, as WordPress treats “Numeric” and “Char” values very differently. As you seems to use these value as Number, you need to provide “meta_type”

Related Posts:

  1. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  2. WP_Query: getting posts where custom field exists
  3. Order a WP_Query by meta value where the value is an array
  4. Efficient way of querying for a “fallback” post?
  5. How to update custom fields using the wp_insert_post() function?
  6. Getting attachments by meta value
  7. How to display multiple Post meta_key/meta_values by SQL query
  8. How to make an meta_query optional?
  9. How to use multiple query with same meta key
  10. How to update single value in multi dimensional Post Meta?
  11. WordPress altering my custom query, How to fix it?
  12. How can update custom meta for all posts
  13. Modern Tribe Calendar wp-query with meta query not working at all
  14. Use ajax to update_post_meta
  15. How to display custom field on homepage
  16. Can an array be used as a meta_query value?
  17. how to increase custom post value by one most efficiently?
  18. Use WP_Query in shortcode
  19. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  20. Random order of WP_Query results with highest meta value
  21. How can I create a list of page titles from custom meta values?
  22. How to make Meta Query case sensitive?
  23. WP Query with custom Shortcode
  24. Fetch Record based on meta key dates
  25. Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
  26. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  27. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  28. how to make members list directory through wordpress post custom meta key.
  29. Large AND OR query timing out
  30. Custom query, checking values of multiple meta keys
  31. Archive post by meta value + 24hours
  32. auto-populating custom nav with all items from custom post type
  33. Non-Closing PHP Query in WordPress Loop
  34. how to get serialized post meta
  35. How to show meta value code HTML after x paragraph
  36. User Meta Value not echoing despite Var_Dump Showing correct string
  37. WordPress loop by meta key that is an array? and how loop multiple arrays
  38. How to store multiple custom meta box
  39. How to hide posts of a specific custom category in WordPress?
  40. Passing an array into WP_Query as a variable
  41. WordPress meta_query >= &
  42. Add a custom class to the body tag using custom fields
  43. Define category ID using get_post_meta
  44. Hide a div when a custom field is empty
  45. WordPress stripping out custom field tags
  46. Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
  47. Order category posts by last word of custom field
  48. Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
  49. How do i create a custom post query when the meta value is an array?
  50. Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
  51. wp_Query with mutuplea values returns all posts
  52. meta_query search names when they have middle initials
  53. How to update custom fields when post is published?
  54. Usermeta data unserialize, extract and display in table in WordPress
  55. Trouble with serialized metadata
  56. Query on a repeater date (acf)
  57. Delete post meta by serialized meta value
  58. Query against multiple locations within single custom post type post
  59. WP post meta – for loop inside for loop
  60. Meta query not showing result properly
  61. When working with a post, almost all wp_postmeta are deleted
  62. Updating Lat and Lng of posts automatically gives sporadic results
  63. WP_query meta_query slow with OR and DATES
  64. Get meta_query value by user meta array
  65. How to use something like meta_query but for fields?
  66. If custom field doesn’t exist, or exists and it’s true show title?
  67. Querying meta values within an array
  68. Metadata on the WP_Post object
  69. Too many if’s and else if’s ?? – Must be better way [closed]
  70. WP query with variables gives no result for specific user
  71. How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
  72. How to show/hide php table rows based on the content of custom fields
  73. Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
  74. extract serialized array to use for wp-query
  75. Conditional featured image with youtube thumbnail
  76. WP_Query meta compare must include ALL array values
  77. meta_query weird behaviour, static int will work, but not user data
  78. Let current user know pending posts counts using wp_query
  79. How to check post meta isset or not empty during publish/save post?
  80. get_terms with specific id order
  81. “pre_get_posts” orderby custom date field in different format?
  82. wp_query – Exclude the first thumbnail from lazy loading on archives
  83. get_post_meta shortcode returns empty field
  84. Trying to get pagination working on WP_Query() post grid
  85. Check the database for a postmeta field
  86. Sort custom post archives by a meta value from a different custom post type?
  87. Combine multiple queries, array_unique returns nothing
  88. Custom Post type Ajax search results
  89. WP_Query sort by meta_value_num or date
  90. Display only upcoming events / Show all events when archive year is selected
  91. Transfer WordPress Login Session to an Extended Webpage on the Same Domain
  92. How to show all the associated posts with specific date of data metabox?
  93. Add post class in custom loop (WP_QUERY)
  94. WP_Query Posts by Metadata from Option Tree
  95. Selecting posts older than the current Unix epoch timestamp
  96. Custom Search Query – include only custom fields and title
  97. Why does WP_Query show only the same post even with different categories and endwhile?
  98. show/hide attachments
  99. WP_Query based on another query on the page
  100. Show post like this image in my newssite [closed]
Categories PHP Tags custom-field, meta-query, php, post-meta, wp-query
Does a blank plugin come with any overhead?
Interim-Login form on frontend

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