No results found. Try again with different words?

Search must be at least 3 characters.

How to Change the Heading Tag for the Related Posts Title?

If you have enabled related posts on your Blog posts, you might have noticed that the Related Posts Title has the <h2> heading tag assigned by default.

You can modify this tag to any other HTML tag by adding a filter to the functions.php file of your Astra Child Theme. If you don’t have a Child Theme installed and activated on your website, please check this article on how to do this

How Can I Do This?

You can use the filter below to change the tag for the Related Posts Title to any other tag. Please follow these steps:

Step 1 – Navigate to Dashboard > Appearance > Theme Editor and select the Child Theme;

Step 2 – Add the filter below to the functions.php file of your Child Theme. You can check this article on adding code to your Child Theme to help you out;

// Filter for changing related posts title heading tag.
add_filter( 'astra_related_posts_title', 'update_related_posts_title_markup', 10, 1 );
function update_related_posts_title_markup( $markup ) {
    $markup = '<div class="ast-related-posts-title-section">';
     $markup .= '<h4 class="ast-related-posts-title">'; // Replace H4 with the tag you need.
 $markup .= 'Related Posts';
 $markup .= '</h4>'; // Replace H4 with the tag you need.
    $markup .= '</div>';
    return $markup;
}

Step 3 – The filter will change the default <h2> tag to <h4> tag. Update this by replacing <h4> in the code with any heading tag needed. Click the “Update File” button to apply changes.

Note:

Please keep in mind that you need to replace the h4 tag with your needed tag in both places within the code to make this work – one is the opening tag, and the other one is the closing tag (just like we have used <h4> in both places in the code above).

Default Tag

Astra Theme - Related Posts Title Default Tag, Astra 3.0+

Heading Tag after adding the Filter

Astra Theme - Related Posts Title Tag with Added Filter, Astra 3.0+
Was this article helpful?
Did not find a solution? We are here to help you succeed.

Related Docs

Astra is Free. Now & Forever.

We believe creating beautiful websites should not be expensive. That's why Astra is free for everyone. Get started for free and extend with affordable packages.

REWIND

YEAR IN REVIEW

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
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