Skip to content

Snippet: Alter Page Header Title String, HTML Tag & Schema

The wpex_page_header_title_args filter can be used to alter the main page header title html tag, string (text) or the schema markup. Here is an example of altering all three values but you only should alter only the value you need to modify.

/**
 * Example for altering the page header title for a custom post type post
 *
 * @since 3.1.2
 *
 */
add_filter( 'wpex_page_header_title_args', function( $args ) {
	if ( is_singular( 'my-custom-post-type' ) ) {
		$args['html_tag']      = 'h1';
		$args['string']        = get_the_title(); // Can also be altered with wpex_title filter
		$args['schema_markup'] = 'itemprop="headline"'; // Can also be altered with wpex_get_schemea filter
	}
	return $args;
}, 40 );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top