Display posts that have "all" of these categories:

So, I’m trying to display posts that are in BOTH of these categories. Not posts that are in one or the other. I’ve looked at the codex and this is what it gives as an example

Display posts that have “all” of these categories:
$query = new WP_Query( ‘category_name=staff+news’ );

I’ve tried this

 	<?php query_posts('category_name=utah+canyoneering' ); ?>

		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        
        <section class="col-lg-4">
        
                
                <h4 class="AdventurePreviewTitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
                      
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img src="<?php the_field('main_canyoneering_image') ?>"/></a>
                
              
        
        </section>
        
	
	<?php endwhile; endif; ?>
    
    <?php wp_reset_query(); ?>

And I’ve tried this

 <?php

		// The Query
		$the_query = new WP_Query('category_name=canyoneering+utah' );
		
		// The Loop
		if ( $the_query->have_posts() ) {
			echo '<ul>';
			while ( $the_query->have_posts() ) {
				$the_query->the_post();
				echo '<li>' . get_the_title() . '</li>';
			}
			echo '</ul>';
		} else {
			// no posts found
		}
		/* Restore original Post Data */
		wp_reset_postdata();

   
   ?>

Based on the codex this should work. The plus sign is supposed to accomplish this.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.