Tagged: Code block, related posts
I need to use the advanced layout editor to create posts, but I want the related posts (based on tags, like what you get using the classic editor). So I’m trying to call ‘includes/related-posts’
1)
I tried placing this code in template-builder.php on line 103 after ‘echo $content;’:
if(is_singular(‘post’)) {
get_template_part( ‘includes/related-posts’);
}
2)
I tried placing it in a code block on the page with this:
<?php get_template_part( ‘includes/related-posts’); ?>
What is the correct way to use the advanced layout editor and add the related post at the bottom?
Hey stupaul22,
You should use the first option. Have you tried it yet?
Best regards,
Victoria
Yes I tried both methods and they do not work. Could you please provide some guidance. I don’t know php (although I can often understand whats happening), I do know html and css.
What is the correct code to get and write the related posts layout (based on tags, like what you get using the classic editor).
See:
http://freshed.wpengine.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-14-at-11.02.29-AM.png (hosted on WPengine)
What file does the code go in?
What line should the code go on?
Thank you so much!
Hi,
Thank you for the update.
The same modification works on our end. We added this code in the template-builder.php file around line 104 or after echoing the content as you described above.
if(is_singular('post')) {
get_template_part('includes/related-posts');
}
The related posts section will display posts that have the same tags by default, so we don’t have to change anything regarding that.
Best regards,
Ismael
Thank you this worked.
Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon