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

Click to rate this post!
[Total: 1 Average: 5]

Leave a Comment

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

Scroll to Top Skip to content