How to Change the HTML Tag for Site Tagline in Astra?
|
/ Documentation /Custom Code Snippets/Astra Header & Footer Filters/ How to Change HTML tag for Site Title and Tagline?

How to Change HTML tag for Site Title and Tagline?

From Astra customizer settings ( Customize > Header > Site Identity > Site Tagline / Site Title ), you can add the Title or a Tagline for your site. A Site Title is the name of your side, and the tagline is a small catchy descriptive line for your site.

Enable Tagline, Astra 3.0+

By default, the Title has Heading 1 tag <H1> while tagline has paragraph tag <p> in HTML structure. You can change this tag to any other HTML tag using the following filters:

  • Change Tag For a Tagline
add_filter( 'astra_site_tagline_tag', 'astra_change_site_tagline_tag' );

/* Function to change tag of Site Tagline.
@param string $tag Default is p tag.
*/
function astra_change_site_tagline_tag( $tag ) {
$tag = 'h6';
return $tag;
}

Note:

1. Above filter will change tag to tag. You can update it as per your requirement.

2. Paste the above code in the child theme’s functions.php file.

This is how your Default tag looks in your code:

Tagline Default Tag, Astra 3.0+

And this is the change from <p> to <H6> in your code after adding the Filter:

  • Change Tag For a Site Title

You can also replace the H1 tag for the Title with span tag using the below filter –

add_filter( 'astra_site_title_tag', 'astra_function_change_site_title' );

/**
* Function to replace h1 tag with span in site title.
*
* @param string $tag This contains the tag used for site titles.
* @return string
*/
function astra_function_change_site_title( $tag ) {
    $tag = 'span';
    return $tag;
}
Tagline Heading Tag, Astra 3.0+

add_filter( 'astra_show_site_title_h1_tag', '__return_true' );
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

This field is required.

REWIND

YEAR IN REVIEW

Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form