How to move related entries under comments in Astra theme

astra theme templates

The Astra theme includes the related posts feature, which you can activate and set to your liking from the WordPress customizer, so you don’t have to install any additional plugins for this functionality.

By default, the related posts added by the Astra theme are added below the content and before the comments, but does it have to be this way?

related posts above comments

You may want related posts to appear below the comments, why?

If comments are an important part of your website and you have related posts before them, many visitors will click on these posts to see more content, and maybe they won’t even get to see the comments, let alone participate in the conversation.

You will say that it is better that they click on other posts to improve the internal traffic of the web, but this is not always the best, remember that comments are also content, and sometimes they are a great indicator of the popularity of a publication, improving its positioning.

Well, there are reasons, but YOU have the decision. If you want to make this change is easy, just add the following to the end of the functions.php file of the Astra child theme:

/* Move related posts below comments */ add_action( 'astra_entry_before', function() { add_filter( 'astra_get_option_enable-related-posts', '__return_false' ); } ); add_action( 'astra_primary_content_bottom', function() { add_filter( 'astra_get_option_enable-related-posts', '__return_true' ); } ); add_action( 'astra_template_parts_content_top', 'action_to_update_related_post_markup', 1 ); function action_to_update_related_post_markup() { $related_post_markup_instance = new Astra_Related_Posts_Markup(); add_action( 'comment_form_after', array( $related_post_markup_instance, 'astra_get_related_posts' ), 10 ); }
Code language: PHP (php)

Save the changes and now the related entries will be displayed under the comments.

related posts below comments

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published.

Scroll to Top
Skip to content