[Resolved] Query Loop to display posts for further reading within blog post

Home Forums Support [Resolved] Query Loop to display posts for further reading within blog post

Home Forums Support Query Loop to display posts for further reading within blog post

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

    Hi,

    Within my blog posts, I like to display posts for further reading here and there in a visually appealing way.

    I currently do this in a cumbersome way and would like to switch to query loops to achieve it.

    I’ve come so far as to insert a query loop in a post and select the query parameter “include posts,” which allowed me to pick the posts I wanted.

    But what I don’t get is how I can style these query loops globally.

    I tried using a Content Template Element and choosing all posts as the location, but then the entire blog posts get overwritten with that template, so this is clearly not how it’s done.

    Can you point me in the right direction?

    #2465829
    David
    Staff
    Customer Support

    Hi there,

    are you using GenerateBlocks Pro ?

    #2465947
    lerschiboi

    Hi, yes I am

    #2466416
    Fernando
    Customer Support

    Hi Lars,

    If it’s creating Related Posts you are looking for there’s a way to do it with GB Pro, here’s an article you may refer to: https://generateblocks.com/creating-related-posts-with-query-loop-block/

    As for adding them Globally, using a Block Element is indeed a good way to do it. You can use a Block Element – Hook and hook it to somewhere like after_content. You can see some other hooks you can use here: https://docs.generatepress.com/article/hooks-visual-guide/

    In this way, you wouldn’t override the main query.

    With GB Pro, you can also opt to start from a Pattern. See here for available Patterns: https://generateblocks.com/library/

    More on Pattern Library here: https://docs.generateblocks.com/article/pattern-library-overview/

    #2466807
    lerschiboi

    Hi Fernando,

    Thanks but that’s not quite what I’m looking for. I’m not looking for a related posts section at a specific part of my blog posts.

    Instead, I want to sprinkle these further reading posts throughout my blog posts wherever it fits. Sometimes I want to reference one post, sometimes two or three. But the posts should always be styled as seen in my screenshot above.

    Query loops seem to be a good starting point as they let me choose specific posts via the “include posts” parameter.

    I can now style this query loop, but I don’t want to do this for every single post. Is there a way to do this globally?

    #2466851
    David
    Staff
    Customer Support

    If you’re using GenerateBlocks Pro, then you can create a Local Pattern to save your Query Loop. Then you can just add that local pattern each time you require it.
    You may also want to creating the GB Global Styles first and building your local template with them first, in case you want to refresh their design in the future.

    #2469642
    lerschiboi

    Thanks David, that works

    #2469662
    David
    Staff
    Customer Support

    You’re welcome

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