How to change HTML tags for site title and subtitle in Astra Theme

exist Astra In the theme.Site Titleindicates the name of the site.subheadingare short and attractive descriptive phrases. By default, Astra uses the following for site titles H1 tags, and for subheadings, use the<p>Tags. If you need to change these labels, you can do so by customizing the filter.

Image [1] - How to change HTML tags for site title and subtitle in Astra theme

Site title and tagline setup

nodecaptionis the name of the site.placardsis a short and compelling descriptive phrase.

To access and modify them, use the Astra CustomizerThe

Images [2] - How to change HTML tags for site title and subtitle in Astra Theme

Astra Customizer

  • show (a ticket) Astra CustomizerThe
  • Navigate to Header Builder > Site Title & LogoYou can add a title and tagline to your website.
Image [3] - How to change HTML tags for site title and subtitle in Astra Theme

Change the HTML tag for the subtitle

By default, site titles use the H1 tags, while the tagline uses <p> Tags. If you need to change these labels, you can change them to something else by using the following filter HTML Tags.

To change subheading HTML tag, you can add the following code to thesubtheme(used form a nominal expression) functions.php Documentation:

add_filter( 'astra_site_tagline_tag', 'astra_change_site_tagline_tag' );

/* A function to change the subtitle tag.
@param string $tag Default is the p tag. */
function astra_change_site_tagline_tag( $tag ) {
    $tag = 'h6'; // Change to whatever tag is desired (e.g. h2, h3, etc.).
    return $tag;
}

This filter will change the default label of the subtitle to (or any selected label).

This is what the default label looked like before the filter was added.

Image [4] - How to change HTML tags for site title and subtitle in Astra Theme

This is after adding the FilterCode from the <p> until (a time) <h6> The change.

Image [5] - How to change HTML tags for site title and subtitle in Astra Theme

Use your browser's Check Elements The tool can confirm the changes.

Image [6] - How to change HTML tags for site title and subtitle in Astra Theme

Changing the title of a website HTML tab (of a window) (computing)

connect Site Title (used form a nominal expression) H1 The tag is replaced with<span> tags, the following filters can be used:

add_filter( 'astra_site_title_tag', 'astra_function_change_site_title' );

/**
* A function that replaces the h1 tag of a site title with a span tag.
*
* @param string $tag This is the tag to use for the site title.
* @return string
*/
function astra_function_change_site_title( $tag ) {
    $tag = 'span'; // Change to whatever tag is desired (e.g. h2, span, etc.).
    return $tag;
}

Mandatory use of H1 tags

If required Force website titles to always use H1 tags, the following filters can be used:

add_filter( 'astra_show_site_title_h1_tag', '__return_true' );

summarize

With the above method, it is possible to flexibly change the nodecaption respond in singing subheading (used form a nominal expression) HTML Tags. This helps to adjust the use of tags according to the actual needs and achieve a more appropriate website structure effect.

Recent Updates


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by: thieves will be rats and mice courage
THE END
If you like it, support it.
kudos215 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments