WP_Query not showing correct amount of posts form custom taxonomy
-
Hi,
I am trying to display posts (CPT) from a specific category with my custom taxonomy. Im pulling my hair out as there has to be a simple explanation as to why my loop will only display one post despite my post_per_page parameters (8). FYI-my CPT is “Cake Flavors”. My taxonomy is also “Cake Flavors” and within the taxonomy i have about 8 categories: vanilla-flavors, chocolate-flavors, spice-flavors…etc. I want to have a page that shows only vanilla-flavors. Below is my loop code:<?php $args = array( 'post_type' => 'cake-flavors', 'posts_per_page' => 8, 'tax_query' => array( array( 'taxonomy' => 'cake_flavors', // Taxonomy name 'field' => 'slug', 'terms' => array ('vanilla-flavors',) ) ) ); // The Query $cake_flavors = new WP_Query( $args ); // The Loop if ( $cake_flavors->have_posts() ) { while ( $cake_flavors->have_posts() ) { $cake_flavors->the_post(); } ?> <div class="small-6 columns"> <div class="row"> <section> <div class="small-12 medium-6 columns"> <h1><?php the_title() ?></h1> <p class="description"><?php the_field('description'); ?></p> </div> <div class="small-7 small-centered medium-6 medium-uncentered columns"> <?php // check if the post has a Post Thumbnail assigned to it. if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } ?> </div> </section> </div> </div> <?php } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata(); ?>
PLeeeeez help! I’m new with WP and a bit overwhelmed so I may be missing something very basic… I tried help from WPMU and I got a canned answer directing me to the codex. I had already read it… Ive read it 1000 times, I still don’t get it… Thanks!
- The topic ‘WP_Query not showing correct amount of posts form custom taxonomy’ is closed to new replies.