How to replace entry title heading tag for a specific Featured Post widget using GFPC

Posted on
5/5 - (329 votes)

In Genesis Slack chat a user asked:

Hey guys… question for you. Would it be possible to change the H4 Widget Title of the Featured Page Widget to H1? What’s needed is the Home Middle Widget Title which is H4 – we want to be H1 for SEO purposes. Does that make sense? Is that doable?

When the requirements involve customizations in Genesis Featured Posts/Page widgets, my go-to method is using Genesis Featured Posts Combo (commercial plugin).

By adding the following in child theme’s functions.php, the default h2 entry titles will be replaced with h1 markup for a specific GFPC widget (having the ID of 5):

// Change h2 markup to h1 for a specific GFPC widget
add_filter( 'gfpc_do_post_title_gfpc-widget-5', 'sk_custom_title', 10, 2 );
function sk_custom_title( $title, $instance ) {

	$replace = 'h2';
	$replace_with = 'h1';

	$title = str_replace( $replace, $replace_with, $title );

	return $title;

}