No results found. Try again with different words?

Search must be at least 3 characters.

How to Display the Post Category as a Related Posts Title?

Sidebar Image

Did not find a solution? We are here to help you succeed.

The Astra Theme comes with the Related Posts feature, which helps you engage your visitors for a longer time. This feature displays posts within the related category, suggesting that your visitors read more content related to their topic of interest. 

Astra Related Posts

Further, you might want to change the Related Posts section title and show the Post Category name instead. You can do this by adding a custom code (filter). 

To do this, you would need to add the following filter to the functions.php file of your Child Theme:

add_filter( 'astra_related_posts_title', 'astra_related_poat_title' );
function astra_related_poat_title() {
   return sprintf(
	'<div class="ast-related-posts-title-section"> <%1$s class="ast-related-posts-title"> %2$s </%1$s> </div>',
	'h2',// enter your custom string here
	esc_html__( get_the_category()[0]->name, 'astra' )
   );
}

Once the filter is added, the Related Posts section title will display the category name of the current post:

Filter to Display the Post Category as a Related Posts Title

If you don’t have your Child Theme installed, please check this article on how to do it.

If you are not sure how to add this code, please check this article

Was this article helpful?
Sidebar Image

Did not find a solution? We are here to help you succeed.

Related Docs

Join 1,653,898+ Happy Site Owners Using Astra

Whether you are a beginner, small business owner, or professional web developer, Astra provides all the tools you need to easily build your beautiful WordPress website.

Download is Just A Click Away!

Membership Retention Checklist Download

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