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;
}
Code language: PHP (php)
The above code must be added to the end of the functions.php
file of the Astra child theme, and you would only have to change the example tag (h3) to the one you prefer.
And you will see this change:


Read this post in Spanish: Cómo cambiar el H1 de los títulos de entrada y página en el tema Astra #SemanaAstra