How to change the H1 of the entry and page titles in the Astra theme

astra theme templates

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:

Original h1
New h3

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

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top