I usually use two steps to retreive a list of posts and the associated metadata: call get_posts(or a custom WP_Query), and then loop through each post returned and retrieve each posts metadata one by one.
Is there any way to combine this into a single query? I guess I’m looking for something like a get_posts_with_meta() function?
It’s not a single step, but it’s easy to write & handle in code:
get_post_custom()
gives you all attached meta data. But be aware: Everything comes as array, even when it´s a single value. SoHere is a snippet of code source: WPSnipp.com
Place this in your functions.php file…
Or using get_post_custom() you can do this;
Place this in your functions.php file…
Then within your theme files you can do the following;
Source HERE
Not worth it as it would be a convoluted query and work against most of the wp caching solutions.