Creating recent/relevant posts like this beneath articles

  • Hi,
    I’m a bit out of the loop but wondered if anything had changed over the year when it comes to adding recent or related posts beneath an article. Have been through many plugins starting with Special Recent Posts etc, but is this now doable in GBlocks? Ss attached, thanks.

  • Hi there,

    Yes, it is possible. However, it requires GenerateBlocks Pro as the related posts functionality relies on features available in the Pro version, specifically the advanced Query block capabilities and dynamic query options.

    Here are some resources you can reference:
    https://docs.generateblocks.com/article/use-query-loop-block-to-create-related-posts/

  • Thanks Alvind, I’ll explore the video and update, cheers

  • Sure, no problem! 🙂

  • Thanks Alvind, just on the free version:

    – you can’t exclude current post?
    – you have to create new query loop for each category?
    – where do you order “after main content” blocks, if say you want to place an ad before or after loop?

    Thanks

  • Hello,

    – you can’t exclude current post?

    Add a new EXCLUDE POSTS parameter and select Exclude current post.

    Related posts - Exclude current post

    – you have to create new query loop for each category?

    If you set the TAXONOMY parameter just how the video shows, it will display related articles that belong to the category of each post at the time. So, categories, will vary. Is that what you are asking?

    Related posts - Current post terms

    – where do you order “after main content” blocks, if say you want to place an ad before or after loop?

    If you want to place an ad before the loop, you would create an element with your add and set the priority to a lower number than 10. eg: 9. The related posts element has a default priority of 10, of course, you could always change that as well.

    Element priority

    For the ad to appear after the related posts element, the priority would need to be higher, eg: 11.

    The lower the priority number, the higher it will appear on the page under the same hook!

  • Thanks but I am talking about the Free version.

    In Query Loop I have:

    Select post type
    Posts

    Posts per page
    4

    Taxonomies
    Categories

    Select terms
    All I can choose are the individual categories

    Ss attached below

  • Hello,

    As stated earlier the related posts functionality required GB Pro (in addition to the GB free version).

  • I stated: Thanks Alvind, just on the free version:

    So I need to set up Q. loops for each individual category is that right?

  • Additionally – I used this snippet that excludes posts from appearing on the same post in the Q. Loop, but also the posts themselves are not linking to their respective posts. Example post included. Only the title of the post in the Q.Loop links but not the image or the Read Article button.

    add_filter( ‘generateblocks_query_loop_args’, function( $query_args, $attributes ) {

    // Only on single posts
    if ( is_single() ) {
    $query_args[‘post__not_in’] = array( get_the_ID() );
    }

    return $query_args;

    }, 10, 2 );

  • Hello,

    That’s correct — on the free version, the Taxonomy parameter only lets you select specific, fixed terms. You would need a separate Query Loop for each category. The dynamic “current post’s terms” option (which automatically shows posts from the same categories as the current post) is a GB Pro feature.

    The image and button not linking is unrelated to the snippet — each element needs its own dynamic link configured individually in the block settings. The title links because it’s set up that way by default; the image and button need the same applied to them separately.

  • Thanks George, I ran the queries by chatgpt prior which begged to differ with regards to having to set up separate category related QL’s with the free version of GB, but I wasn’t convinced either so thank you for clearing that up. Appreciated.

    Regarding dynamic links needed for making the image and button clickable, wld you mind clarifying how this is done; I’ll explore also, cheers.

  • Ignore, sorted, cheers.

  • No problem!

  • Oooh, just one thing, all my posts in the QL are ordered by most recent, is there a way to order them differently, maybe randomly so if the reader goes on to read another post, when they get to the end of that post they don’t see the same posts that were listed in the previous QL?

  • Hi Rob,

    Yes, that’s possible. You just need to add a random ordering parameter to the Query block, but that functionality is available only in GenerateBlocks Pro.

    It can still be achieved in the free version, but it would require a custom code snippet. Let us know if you’d like to go that route.

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