How to set Heading tags for Entry Titles in Genesis conditionally

Posted on

A user in Genesis Facebook asks:

how to wrap portfolio items on archive-portfolio.php in h3 and not in h2 tags? i am using this plug in (https://github.com/copyblogger/genesis-portfolio-pro) thanks so much

genesis_entry_title_wrap filter hook can be used to change the heading tags from the default h1 (if HTML5 with semantic headings) or h2 to another, say h3 like so:

// Wrap entry titles on 'portfolio' post type archive page in h3 tags
add_filter( 'genesis_entry_title_wrap', 'sk_set_custom_entry_title_wrap' );
function sk_set_custom_entry_title_wrap( $wrap ) {

	if ( is_post_type_archive( 'portfolio' ) ) {
		$wrap = 'h3';
	}

	return $wrap;

}

Adding the above in child theme’s functions.php will change the entry titles wrapper from to h3 for all entries on the portfolio CPT archive page.