[Support request] Adding related posts to blog pages

Home Forums Support [Support request] Adding related posts to blog pages

Home Forums Support Adding related posts to blog pages

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #955029
    Leapforce

    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!

    #955043
    David
    Staff
    Customer Support

    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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.