I am learning to create a Portfolio section. I already created the custom post type and a custom taxonomy for the portfolio categories. The categories are working ok, i can choose which category i want for every portfolio item.
I am trying to loop within the post_type portfolio to get the items and it works ok, but i cannot get the categories of each item.
<?php $loop = new WP_Query( array( 'post_type' => 'portfolio') ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="panel">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p><?php the_content(); ?></p>
<p><?php the_category(); ?></p>
</div>
<?php endwhile; wp_reset_query(); ?>
I am using the above code, but the categories dont show up.
I tried separately to display the categories and are working ok with this code:
<?php
$args = array( 'taxonomy' => 'portfolio_categories', );
$categories = get_categories($args);
foreach($categories as $category) { ?>
<?php echo $category->name;?>
<?php }
?>
So how can i display each portfolio item categories in the loop ?
Try following code, this will print all custom taxonomies of post.