DPS, Use h2 for post title

/**
 * Display Posts Shortcode, Use h2 for post title
 * @link https://www.billerickson.net/code/dps-use-h2-post-title/
 */
function be_dps_post_title_h2( $output, $original_atts, $image, $title ) {
	if( !empty( $original_atts[ 'post_title_as_h2' ] ) && true === filter_var( $original_atts[ 'post_title_as_h2' ], FILTER_VALIDATE_BOOLEAN ) ) {
		$new_title = '<h2>' . $title . '</h2>';
		$output = str_replace( $title, $new_title, $output );
	}
	return $output;
}
add_filter( 'display_posts_shortcode_output', 'be_dps_post_title_h2', 10, 4 );

Original support ticket

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk