I have a meta key which I would like to use to get all post meta data for a post where that one meta key matches a specific value, in one go.
Example: Post 1
has a meta_key
called unique_number
. I want to query for all the occurences where unique_number
is a specific value, and then get all the meta data for the posts where unique numner
is that value.
The way I found to do it now, is this way:
$args = array(
'meta_key' => 'unique_number',
'meta_value' => '12345'
);
$posts = get_posts( $args );
...then I have to loop through the result and use get_post_meta to fetch the meta data.
Is it possible to do this in one query, except many, with built in Wordpress functions, or do I have to write my own custom mysql query?