• Tim

    (@thegreentimtam)


    So, I’m trying to create a loop that displays everything of a post type ‘photo-albums’ in the category ‘circus’. I am just using the standard built in category taxonomy. What I have at the moment is the following:

    <?php $album_loop = new WP_Query( array('category' => 'circus', 'post_type' => 'photo-albums', 'posts_per_page' => '10', 'orderby' => 'menu_order' ) ); ?>
    
    	 	<?php while ( $album_loop->have_posts() ) : $album_loop->the_post(); ?>

    This is displaying posts in all categories. What am I doing wrong?

Viewing 1 replies (of 1 total)
  • Thread Starter Tim

    (@thegreentimtam)

    Sorted – I found a solution online.

    <?php $args = array(
                        'post_type' => 'photo-albums',
                        'posts_per_page' => 10,
                        'tax_query' => array(
                                               'relation' => 'AND',
                                               array(
                                                      'taxonomy' => 'category',
                                                      'field' => 'slug',
                                                      'terms' => array(
                                                                        'circus'
                                                                       )
                                                    )
                                            )
                      ) ;
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘A Loop with Specific Category and Taxonomy’ is closed to new replies.