get post category name wordpress code example
Example 1: wordpress get post category name
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name );
}
?>
Example 2: wordpress display post categories
<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>
Example 3: Get wordpress posts by category name..!
<?php query_posts('category_name=CATEGORYNAME&showposts=5');
while (have_posts()) : the_post(); ?>
the_title();
the_content();
<?php endwhile; ?>