How To Change The H1 Of The Entry And Page Titles In The Astra Theme?

When I published the other day how to change the H2 headers of the widget in Astra, one of the questions I was asked right away was “and how do I change the H1 of the entry and page titles?

According to whoever asked me, on their website he/she preferred the titles not to have such a hierarchy, as always for SEO purposes, so here is the code to add to your Astra

/* Change H1 HTML tag from titles to H3 */
add_action( 'wp', 'astra_add_title_filter' );

function astra_add_title_filter() {
add_filter( 'astra_the_title_before', 'astra_the_title_before_tag', 1, 10 );
add_filter( 'astra_the_title_after', 'astra_the_title_after_tag', 1, 10 );
}

function astra_the_title_before_tag( $tag ) {
$tag = '<h3>';
return $tag;
}

function astra_the_title_after_tag( $tag ) {
$tag = '</h3>';
return $tag;
}