Displaying Category Headings on all Category Archive Pages in Genesis

In a Genesis WordPress theme you can add in a headline to display for a Category archive page, but this headline only appears on the initial category archive page, so  if pagination exists for subsequent archive pages then other pages do not have the title rendered.

genesis-category-heading

 

To get around this issue if you have pagination on your category archives the problem is better solved with a function in your themes function.php file

function themeprefix_category_header() {
if ( is_category() )  {
		echo '<h1 class="archive-title">';
		echo single_cat_title();
		echo '</h1>';
	}
}
add_action( 'genesis_before_loop' , 'themeprefix_category_header' );

The function above will only run if the content is a category page and then render the actual category title in h1 tags with a class of archive-title set to it. It will display on all the same category archive pages.

If you wanted something other than the category title you drop the single_cat_title for something else…

function themeprefix_category_header() {
if ( is_category() )  {
	echo '<h1 class="archive-title">Your Heading Here</h1>';
	}
}
add_action( 'genesis_before_loop' , 'themeprefix_category_header' );

 

The action will place the archive heading just outside of the loop.

genesis-category-before-loop

This can also be applied to tags

function themeprefix_tag_header() {
if ( is_tag() )  {
		echo '<h1 class="archive-title">';
		echo single_tag_title();
		echo '</h1>';
	}
}
add_action( 'genesis_before_loop' , 'themeprefix_tag_header' );

A lot of sites won’t have a need for this but when those archives build over time or a small amount of posts per archive page is applied its a handy setting to add.

Gist.