can I somehow display posts that satisfy the custom field values that I need:
for ex, display all posts that have the value A from the field X, and value B from the field Y
and I need to display them only if they have both the values i need.
I was using the code below, but it shows posts that have values A or B, but I need to display them just if they have exactly the two i specify in the query loop.
<?php query_posts('meta_key=color&meta_value=black &meta_key=shape&meta_value=circle&orderby=title&order=asc'); ?> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> , <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'color', true); ?> <?php endwhile;?>
How to filter that?
- The topic ‘Query posts by custom fields value’ is closed to new replies.