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. Display posts in correct month order using single date custom field
  6. How to update custom fields using the wp_insert_post() function?
  7. Getting attachments by meta value
  8. How to display multiple Post meta_key/meta_values by SQL query
  9. How to make an meta_query optional?
  10. How to use multiple query with same meta key
  11. How to update single value in multi dimensional Post Meta?
  12. WordPress altering my custom query, How to fix it?
  13. How can update custom meta for all posts
  14. Modern Tribe Calendar wp-query with meta query not working at all
  15. Use ajax to update_post_meta
  16. How to display custom field on homepage
  17. Can an array be used as a meta_query value?
  18. how to increase custom post value by one most efficiently?
  19. Use WP_Query in shortcode
  20. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  21. Random order of WP_Query results with highest meta value
  22. How can I create a list of page titles from custom meta values?
  23. How to make Meta Query case sensitive?
  24. WP Query with custom Shortcode
  25. Fetch Record based on meta key dates
  26. Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
  27. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  28. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  29. how to make members list directory through wordpress post custom meta key.
  30. Large AND OR query timing out
  31. Custom query, checking values of multiple meta keys
  32. Archive post by meta value + 24hours
  33. auto-populating custom nav with all items from custom post type
  34. Non-Closing PHP Query in WordPress Loop
  35. how to get serialized post meta
  36. How to show meta value code HTML after x paragraph
  37. User Meta Value not echoing despite Var_Dump Showing correct string
  38. WordPress loop by meta key that is an array? and how loop multiple arrays
  39. How to store multiple custom meta box
  40. How to hide posts of a specific custom category in WordPress?
  41. Passing an array into WP_Query as a variable
  42. WordPress meta_query >= &
  43. Add a custom class to the body tag using custom fields
  44. Define category ID using get_post_meta
  45. Hide a div when a custom field is empty
  46. WordPress stripping out custom field tags
  47. Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
  48. Order category posts by last word of custom field
  49. Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
  50. How do i create a custom post query when the meta value is an array?
  51. Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
  52. wp_Query with mutuplea values returns all posts
  53. meta_query search names when they have middle initials
  54. How to update custom fields when post is published?
  55. Usermeta data unserialize, extract and display in table in WordPress
  56. Trouble with serialized metadata
  57. Query on a repeater date (acf)
  58. Delete post meta by serialized meta value
  59. Query against multiple locations within single custom post type post
  60. WP post meta – for loop inside for loop
  61. Meta query not showing result properly
  62. When working with a post, almost all wp_postmeta are deleted
  63. Updating Lat and Lng of posts automatically gives sporadic results
  64. WP_query meta_query slow with OR and DATES
  65. Get meta_query value by user meta array
  66. How to use something like meta_query but for fields?
  67. If custom field doesn’t exist, or exists and it’s true show title?
  68. Querying meta values within an array
  69. Metadata on the WP_Post object
  70. Too many if’s and else if’s ?? – Must be better way [closed]
  71. WP query with variables gives no result for specific user
  72. How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
  73. WordPress yoast seo plugin – parse snippet var in meta description
  74. Custom route and query
  75. Display posts with specific value first in query
  76. if custom field doesn’t exist, use post thumbnail instead, as image background
  77. change the default order of posts only for specific categories
  78. Get every post with value in meta key
  79. WP All Import / Update stock quantity from multiple XML files
  80. Getting posts to exclude from array
  81. Get all posts as an array ID => Name
  82. Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
  83. How to insert wp_users ->user login name to wp_terms when a new user registering?
  84. Undefined offset: 0-wp-includes/meta.php:488 -Melding
  85. change order of images attached to post
  86. Post not populating for custom post type based on category selection
  87. Custom query vars filters problem with pagination
  88. Custom post type permalinks do not appear using the link functions
  89. extract serialized array to use for wp-query
  90. Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
  91. WP_Query multiple post results
  92. How to add post meta in while loop?
  93. Add category to post meta
  94. Modify main query before it run without pre_get_post
  95. Handling repeater data
  96. WordPress WP_Query without query GET parameters
  97. How to add data to a custom field at the wp_users table?
  98. Using rules in Posts
  99. Sort posts in a specific way
  100. Problem with adding custom CSS class to image in ACF Photo Gallery plugin [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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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