

To achieve this recipe, simply find the loop and add the query_posts() function just above, as in the example below:
<?php query_posts('meta_key=review_type&meta_value=movie'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
You'll get the list of post having review_type as a custom field key and movie as a value. Just change theses values to fit your needs.
18 Responses
Thanks jbj
Another great tip, nice on JBJ.
what if there are more than one key/value?
Hello admin, please tell me how to add a post thumbnail without a plugin. Thank you very much!
Thanks.
This is a good one, though I tried to use it a while back and found out that it wasn’t good for the type of Custom Field I had created. I figured instead of doing ‘yes’ or ‘no’ meta values for my fields, I use the classic binary ‘0′ and ‘1′, only to find out that calling ‘meta_key=whatever&meta_value=0′ completely ignores the second parameter…
If you need to fetch custom fields whose value needs to be ‘0′, you’ll have to use a Custom SELECT query, instead.
I also never figured out how to pass multiple meta_keys and their respective values using just the query_post() function above, so anyone trying to do that can resort to SELECT as well.
Thanks for another great tip!
hello,
how to count the total number of posts with the specific value of custom field?
bye
if i want to search multiple meta field values then what should i do ??
Thanks! This helped me!
Hi!
In my blog a have this query:
query_posts($query_string.’&showposts=10&meta_key=TEST’);
ok, it works and bring to me 10 posts with TEST in custom field, but my doubt is how i brings only posts with empty custom fields, because i have 2 queries, one show just TEST posts, and other must show all less first query, avoinding duplicated posts.
can u help me? hugs!
Trackbacks: