Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1309496

    Hello,
    I have used Enfold for a website and I need to add related posts at the bottom of my articles. I have already looked for some information on the forum and have sometimes read about a plugin made especially for Enfold but it doesn’t seem to exist anymore.
    I also understand that having built the article with ALB the related articles do not appear (but why?). I tried some shortcodes but they don’t work, is there one usable? Otherwise there are other methods to use, possibly without installing other plugins.
    Thank you

    #1309681

    Hey marco_adinolfi,

    Thank you for the inquiry.

    You can modify the template-builder.php file directly to include the related posts for posts that have been created using the advance layout builder. Example here:

    // https://kriesi.at/support/topic/single-post-use-advanced-layout-editor-and-place-related-posts-at-bottom/#post-1246328

    You can also use the avf_template_builder_content if you do not want to edit the template file directly, or you can create a custom shortcode that renders the related posts section.

    // https://kriesi.at/support/topic/related-entries-3/#post-1166140

    Best regards,
    Ismael

    #1309847

    Hi Ismael, thank you for your reply.
    I didn’t want to edit the template-builder.php file directly and I’d like to choose where to add the related post element, but for me it was the only solution that worked. I made a copy of template-builder.php in Enflod-Child to avoid problems.

    I was thinking about using the others solutions that you gave me, but I didn’t understand how to use avf_template_builder_content and the solution explained here didn’t work for me, I don’t know why but it still displays [rposts] as a text and not as an element.
    Could you explain me how to use avf_template_builder_content and what mistakes I could have done inserting

    /* related posts shortcode = [rpost] */
    function related_posts_shortcode( $attr ) {
        ob_start();
        get_template_part( 'includes/related-posts' );
        return ob_get_clean();
    }
    add_shortcode( 'rpost', 'related_posts_shortcode' );

    inside my enfold-child function.php file?
    Thank you again

    #1309932

    Hi,

    Thank you for the update.

    This is an example of the avf_template_builder_content filter. You can add it in the functions.php file.

    function avia_add_social_toolbar_template_builder($content = "")
    {
        if (!is_singular("post")) return;
        ob_start();
        get_template_part( 'includes/related-posts' );
        $related = ob_get_clean();
    
        $content .= $related;
        $content .= '';
        return $content;
    }
    add_filter('avf_template_builder_content', 'avia_add_social_toolbar_template_builder', 10, 1);
    

    This should render the related post section below the ALB content.

    Best regards,
    Ismael

    #1310111

    Ok I tried it and it seems to me it works the same way as the code

    if(is_singular('post')) {
    	get_template_part('includes/related-posts');
    }

    added in the “template-builder.php” file, so it ALWAYS makes any related articles appear in every article, right? Doesn’t it let me choose and doesn’t add any content elements or options to the advanced layout builder? I ask you to make sure I understand and use this function correctly.
    In the meantime, however, I also managed to add the shortcode to function.php, so I have a different option, but by now I would like to deepen and fully understand how all these options work.
    Thank you

    #1310530

    Hi,
    Thank you for your patience, I will try to explain how these work, basically they all work the same and give you no new options or elements, the related articles are meant to show on posts created with the default WordPress editor, and the post tags are what determine what are shown, so the post must have tags for the element to show and the other posts must also have tags.
    So the reason these codes have been offered is some people use the Advanced Layout Builder for their posts and the related articles were not meant to show with that builder, so you would add this code to the template. The related posts shortcode solution [rpost] allows you to add the shortcode for the related posts in the Advanced Layout Builder where you want it to show, such as a code block element, this is the only difference. This shortcode solution still works I have tested it

    /* related posts shortcode = [rpost] */
    function related_posts_shortcode( $attr ) {
        ob_start();
        get_template_part( 'includes/related-posts' );
        return ob_get_clean();
    }
    add_shortcode( 'rpost', 'related_posts_shortcode' );

    2021-07-17_004.jpg
    I hope this answers your questions

    Best regards,
    Mike

    #1312348

    Hello Mike,
    Thank you very much for the explanation and the example, now it is clearer to me how the various options work.
    Best regards

    #1312371

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Add Related Post’ is closed to new replies.