Support » Fixing WordPress » How to get Query to do an AND search instead of an OR search.

  • ashleyhancock

    (@ashleyhancock)



    I’m trying to create a loop that displays accommodation in Europe (ID: 14), however everything I’ve tried shows all posts that are in Europe, regardless of post type.

    This is the code I have currently:

    $args = array(
    	'post_type'=> 'accommodation',
    	'cat' => '14',
            'post_status' => 'publish'
    );
    
    // The Query
    query_posts( $args );
    
    // The Loop
    while ( have_posts() ) : the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;
    
    // Reset Query
    wp_reset_query();

    If I just have the below argument then only accommodation posts are displayed:

    $args = array(
    	'post_type'=> 'accommodation',
            'post_status' => 'publish'
    );

    Any help would be appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to get Query to do an AND search instead of an OR search.’ is closed to new replies.