How to change H tag in page headline?
Title in page headline is, by default, set to use h1 tag.
In order to change the tag, you will need to customize part of the theme's code, so some familiarity with PHP is necessary.
First, install and activate the child theme. Then, to child theme's functions.php file add the following code, and edit the H tag according to your needs:
if ( ! function_exists( 'boldthemes_get_heading_html' ) ) {
function boldthemes_get_heading_html( $superheadline, $headline, $subheadline, $headline_size, $dash, $el_class, $el_style, $header = false ) { if ( $header ) {
if ( MedicareTheme::$what == 'index' && MedicareTheme::$boldthemes_page_for_header_id ) {
$page = get_post( MedicareTheme::$boldthemes_page_for_header_id );
$headline = $page->post_title;
$excerpt = $page->post_excerpt;
if ( $excerpt != '' ) {
$subheadline = '<div class="btSubTitle">' . $excerpt . '</div>';
}
} else if ( MedicareTheme::$what == 'search' ) {
$headline = esc_html__( 'Search', 'medicare' );
} else if ( MedicareTheme::$what == 'woocommerce' && ! is_singular() && wc_get_page_id( 'shop' ) ) {
$page = get_post( wc_get_page_id( 'shop' ) );
$superheadline = '';
$headline = $page->post_title;
$excerpt = $page->post_excerpt;
if ( $excerpt != '' ) {
$subheadline = '<div class="btSubTitle">' . $excerpt . '</div>';
}
} else if ( is_page() ) {
$page = get_post( get_the_ID() );
$excerpt = $page->post_excerpt;
if ( $excerpt != '' ) {
$subheadline = '<div class="btSubTitle">' . $excerpt . '</div>';
}
}
} else {
if ( $superheadline != '' ) {
$superheadline = '<div class="btSuperTitle">' . $superheadline . '</div>';
} if ( $subheadline != '' ) {
$subheadline = '<div class="btSubTitle">' . $subheadline . '</div>';
}
}
$h_tag = 'h1';
$class = ''; $style_attr = '';
if ( $el_style != '' ) {
$style_attr = 'style="' . esc_attr( $el_style ) . '"';
} if ( $headline_size != 'no' ) {
$class .= $headline_size;
}
if ( $headline_size == 'extralarge' || $headline_size == 'huge' ) {
$h_tag = 'h1';
} else if ( $headline_size == 'large' ) {
$h_tag = 'h2';
} else if ( $headline_size == 'medium' ) {
$h_tag = 'h3';
} else {
$h_tag = 'h4';
} if ( $dash == 'yes' ) {
$dash = 'top';
}
if( $dash != 'no' && $dash != '' ) {
$class .= ' btDash ' . $dash . 'Dash';
} if ( $el_class != '' ) {
$class .= ' ' . $el_class;
}
$output = '<header class="header btClear ' . $class . '" ' . $style_attr . '>';
$output .= $superheadline;
if ( $headline != '' ) {
$pattern = "/<(strong|b|u|i)([> ])/";
$replace = '<$1 class="animate">';
$headline = preg_replace($pattern, $replace, $headline);
$output .= '<div class="dash"><' . $h_tag . '><span class="headline">' . $headline . '</span></' . $h_tag . '></div>';
}
$output .= $subheadline;
$output .= '</header>'; return $output;
}
}