Site logo

Archived topic

Adding related posts to blog pages

1 reply · Started by Leapforce on July 11, 2019

Viewing posts 1–2 of 2

Hi GeneratePress,

We want to show related posts on our blog pages. We are using the Beaver pagebuilder. I installed this plugin: https://nl.wordpress.org/plugins/related-posts-by-taxonomy/ and added a saved row for Page Builder with this widget.

Then I added this code to the functions.php, found on this documentation page: https://kb.wpbeaverbuilder.com/article/384-add-rows-and-modules-to-index-archive-and-post-pages


function my_page_footer() {
  if (is_home() || is_single() || is_archive()) {
      echo do_shortcode('[fl_builder_insert_layout slug="gerelateerde-artikelen"]');
  }
}
add_action('fl_after_content', 'my_page_footer');

But this doesn't seem to work. Is there something wrong with this code? Or are there better ways to get a widget, or related posts on the blog page?

Thanks in advance!

Hi there,

that code looks like it specific to the BB theme.

Instead create a new Hook Element:

https://docs.generatepress.com/article/hooks-element-overview/

Just add the shortcode part of the code:

echo do_shortcode('[fl_builder_insert_layout slug="gerelateerde-artikelen"]');

Select the before_footer Hook from the list - you can see where the other main hooks are here:

https://docs.generatepress.com/article/hooks-visual-guide/

Check the Execute PHP and Shortcode boxes.

Then set your display rules for Front Page, Post Archives, Posts

This archived topic is closed to new replies.