wordpress - Cant' Display Custom Post Type Title Base on Taxonomy Terms -
trying list custom post type titles based on filtered custom taxonomy terms getting list of post titles instead of getting list of queried post. here code using:
<?php $loop = new wp_query( array( 'post_type' => 'photos', 'technique' => 'zevar', 'post_child' => 0, 'posts_per_page' => 10 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?>
as can see have custom post type called "photos" , custom taxonomy registered "technique". under taxonomy "technique" have terms 1 of them "zevar". can please let me know doing wrong here?
your taxonomy query not correct. check following code.
<?php $loop = new wp_query( array( 'post_type' => 'photos', 'tax_query' => array( array( 'taxonomy' => 'technique', 'field' => 'slug', 'terms' => 'zevar' ) ), 'posts_per_page' => 10 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?>
reference on how use taxonomy parameter https://codex.wordpress.org/class_reference/wp_query#taxonomy_parameters
Comments
Post a Comment