So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to display results, but I am unable to print the category that's linked to each post.
This is my code:
<?php $args = array( 'post_type' => 'staff', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'departments', 'field' => 'slug', 'terms' => 'board' ) ) ); $loop = new WP_Query( $args ); ?> <?php if( $loop->have_posts() ): ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <p class="text-center name"><?php the_title(); ?></p> <?php the_category(' '); ?> <?php endwhile; ?> <?php endif; ?>
I think the problem is that I'm using but I'm not sure.
Any ideas what could be wrong?