Quantcast
Channel: Question and Answer » meta-query
Viewing all articles
Browse latest Browse all 36

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

$
0
0

Under 4.5, I have posts with meta_key as series and meta_value as 19, 20, etc

I am trying to loop through them in a template, and I guess I’m a special kind of dense.

Most recently I have tried

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

$posts = new WP_Query( $args );

It seems to return empty objects, or a result of one, depending on what I change.

Is there some trick to looping through, maybe?


Viewing all articles
Browse latest Browse all 36

Trending Articles