How to add Category name to post title (H1)? “PostTitle + CategoryName”?
My h1 post title code:
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
2 Answers
I would work the code arround and do something like this.
<h1><?php echo get_the_title(); ?> - <?php the_category(', '); ?></h1>
get_the_title();
Retrieve post title.
the_category(', ');
Displays links to categories, each category separated by a comma (if more than one).
Documentation can be founded here : https://codex.wordpress.org/Function_Reference/the_category
Hope it helps you.