Can’t display CPT terms
-
Hello!
I’ve a series of Custom Post Types.
Those posts have some categories and i need to display those value within the loop.So i retrive my custom post type:
$args = array( 'post_type' => 'store', 'store_type' => 'MyStore', 'posts_per_page' => '-1'); $myQuery = new WP_Query($args); if ($myQuery->have_posts()) : while ($myQuery->have_posts()) : $myQuery->the_post(); the_title(); //here i want to display terms of the current post $terms = get_the_terms( $post->ID , 'store_brand' ); if ( is_array( $terms )) { foreach ($terms as $term) { echo $term->name . '<br/>'; } } endwhile; wp_reset_postdata(); endif;
The problem is that when i have to display term name, for some reason some posts have categories but aren’t displayed and other have categories and are displayed many times (the same).
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Can’t display CPT terms’ is closed to new replies.