• Hello

    what am I trying to do is query all posts containing the same custom fields, but only if they satisfy ALL custom fields in the query..

    example:

    the normal query :

    <?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>&nbsp;,&nbsp;
    
      <?php
       global $wp_query;
       $postid = $wp_query->post->ID;
       echo get_post_meta($postid, 'color', true);
      ?>
    
      <?php endwhile;?>

    with this query i got all the posts containing the custom field value “black” OR “circle” but I want to display the post link just in case it has got exactly the two values, and not only one.

    How should the code look for that?

    Thank you

The topic ‘Query posts by custom fields, conditional query’ is closed to new replies.