Custom Post Type – Output taxonomy choice

I am using a WordPress custom post type called “Portfolio” and I am using the following markup to generate my portfolio items:

<ul class="projects">

<?php $loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <li class="project category-slug">
         <h2><?php the_title(); ?></h2>

<?php endwhile; wp_reset_query(); ?>


Now I have a custom taxonomy linked to this custom post type called ‘locations’ which has several categories within it.

I want to output the taxonomy category slug within the above loop (where it says category-slug).

I have tried several of the code examples I have found within the WordPress codex and other websites but they unfortunately do not work with my custom post type.

Thanks in advance.

Read more here: Custom Post Type – Output taxonomy choice

Leave a Reply

Your email address will not be published. Required fields are marked *