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