Display category names of custom post type
-
Hey guys,
searching for a way to display the category names of my custom post type. It would be nice to display categories and their permalinks, but the get_the_category(); function only echo an array. I am surprised that there is no simple function. Is there a smart way?
<?php $args = array( 'posts_per_page' => -1, 'post_type' => 'myposttype', ); $myposttype_array = new WP_Query( $args ); if( $myposttype_array->have_posts() ) { $counter = 0; while( $myposttype_array->have_posts() ) { $myposttype_array->the_post(); ?> <?php echo get_the_category();> <h1><?php the_title() ?></h1> <?php //the_excerpt(); ?> <?php the_content(); ?> <?php $counter++; } } else { echo 'nothing.'; } ?>
Thanks in advance,
Christian
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display category names of custom post type’ is closed to new replies.