10 Useful WordPress Loop Hacks | Developer's Toolbox | Smashi...
Popularity Report
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
URL Tag Cloud
Bookmark History
Saved by 32 people (-2 private), first by anonymouse user on 2009-06-10
Public Sticky notes
Highlighted by liishygo
Highlighted by liishygo
query_posts() function with the meta_key and meta_value parameters:
Highlighted by liishygo
4. Get Posts With A Specific Custom Field And Specific Value

The problem.
Because of the popularity of WordPress’ custom fields, you will often want to be able to output a list of posts with a specific custom field and specific value. While so simple for advanced WordPress users, beginners continue to ask me about this on my blogs. So, here’s the correct and easy way to achieve this.
The solution.
Not hard at all. We only have to use the query_posts() function with the meta_key and meta_value parameters:
1 | <?php query_posts('meta_key=review_type&meta_value=movie'); ?> |
2 | <?php if (have_posts()) : ?> |
3 | <?php while (have_posts()) : the_post(); ?> |
Code explanation.
Definitely nothing hard here. To get only posts with a specific custom field and specific value, you have to use the query_posts() function with the meta_key and meta_value parameters. The meta_key value is the name of the desired custom field, and meta_value is the desired value.
Source
- How to Only Show Posts With a Specific Custom Field
- Easily get posts with a specific custom field/value on your WordPress blog
5. List Upcoming Posts
Highlighted by eliwagar


Public Comment