Taxonomy in loop
Can anyone please tell me if you have an idea why doesn’t this work :
<?php $args = array( 'tax_query' => array( array( 'taxonomy' => 'locations', ) ) ); $query = new WP_Query( $args ); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <h2> <a href = "<?php the_permalink(); ?>" rel = "bookmark" title = " <?php the_title_attribute(); ?>" alt = " <?php the_title_attribute(); ?>" > <?php the_title(); ?> </a> </h2> <?php endwhile; ?> <?php else : ?> <h2>Sorry nothing Found</h2> <?php endif; ?>
I obviously have created to taxonomy in my functions.php, one of them is called ‘locations’ and I have a few posts connected to it, problem is the loop ignores my new WP_query and shows all of them, if I specify only one term (‘locations’ => ‘vejer’) it does work but I can’t seem to be able to tell the loop to show all posts under ‘location’ when trying to do that I get all posts.
- The topic ‘Taxonomy in loop’ is closed to new replies.