Want to add the H1 tag to website logo in the Astra theme for SEO reasons? While inner pages have their page title as H1 tag, you may want to wrap logo with H1 tag for homepage only when using Astra theme. This can be achieved via custom code.
Code Snippet: Add H1 tag to Homepage Logo
In the WordPress Dashboard, go to Appearance > Theme Editor and open the functions.php file of your Astra child theme. Then add the following code at the end. Alternatively, you can use code snippets plugin for adding custom code.
add_filter( 'astra_logo', 'wpd_astra_logo_wrap_h1' ); function wpd_astra_logo_wrap_h1( $html ) { if( has_custom_logo() && ( is_home() || is_front_page() ) ) { $html = str_replace( '<span ', '<h1 ', $html ); $html = str_replace( '</span>', '</h1>', $html ); } return $html; }