Site logo

[Support request] Loop Template

Home Forums Support [Support request] Loop Template

Home Forums Support Loop Template

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #2523167
    Benny

    Ist this doable with the loop template or do i have to to this with css afterwards?

    Link to the picture –> https://ibb.co/TYQZrgW

    #2523184
    Benny

    For the greater “picture”, i want the first 4 posts to be like this, then hook something in between and afterwards, there are normal posts that are older and behave “normal”. I attached a picture to better explain what i want to do.

    –> https://ibb.co/smJ8zfN

    #2523396
    David
    Staff
    Customer Support

    Hi there,

    is this just for the Blog page or All Archive pages ?

    #2523407
    Benny

    All archives

    #2523495
    David
    Staff
    Customer Support

    To create a Loop template that has a separate hero loop and a main loop

    Ok, its possible, but its quite complicated and theres currently a pagination bug that will be fixed in GB 1.7.

    The steps would be:

    1. Add new Loop template.
    2. Add a Container for the hero, inside add 2 column grid.
    3. In each column add a query loop –
    3.1 first loop will be to show one posts and should have a class of list-one
    3.2 second loop to show the the other column with the next 3 posts and should have a class of list-two
    4. After this your static section.
    5. Then your final loop to show the rest of the posts with a class of list-three

    NOTES:
    For All query loops: enable: Inherit the Query from Template DO NOT set any Parameters
    The class should get added the Advacned > Additional CSS Class(es) of the Query Loop -> Grid Block

    6. The display rules location should be set to ALL Archives.
    7. Publish that

    Now each of the posts lists needs it paging and offet params set. To do this you can use the generateblocks_query_loop_args filter hook – heres an example of that code:

    
    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
        // Check your logic to apply the filtering only to specific loop
        if (
            !empty( $attributes['className'] )
            && ! is_admin() ) 
            {
                // list-one set pages to 1 and offset by 0
                if ( strpos( $attributes['className'], 'list-one' ) !== false ) {
                    return array_merge( $query_args, array(
                        'posts_per_page' => 1,
                        'offset' => 0,
                    ) );
                } 
                // list-two set pages to 3 and offset by 1
                elseif ( strpos( $attributes['className'], 'list-two' ) !== false ) {
                    return array_merge( $query_args, array(
                        'posts_per_page' => 3,
                        'offset' => 1,
                    ) );
                }
                // list-three offset by 5 
                elseif ( strpos( $attributes['className'], 'list-three' ) !== false ) {
                    return array_merge( $query_args, array(
                        'offset' => 4,
                    ) );
                }
            
        }
    
        return $query_args;
    }, 10, 2 );

    For the bug, the offets aren’t getting applied to the Query Loops Pagination so it can lead to a mismatch when used.
    Its being fixed in 1.7 which should be out mid february.
    `

    #2524189
    Benny

    Works just fine –> http://app-gulgowski.2xaf1tm1wr-rz83ynk206d7.p.temp-site.link/category/thailand/

    Thank you <3

    PS: I upgraded to GB 1.7 (because this site wont go online before mid february) and i love it!

    #2524192
    Benny

    One thing i forgot to mention: The isnt exactly right. Do you have an idea why this is?

    Nevermind, i duplicated blogposts and didnt change the time. Its working just fine. Thanks again.

    #2524349
    David
    Staff
    Customer Support

    OH wow, i am amazed – i wrote that on the fly and it worked 🙂

    Glad to hear that!

    #2541744
    Benny

    One thing that does not seem to work is pagination. Any idea how to fix this?

    Thank you!!

    #2542426
    David
    Staff
    Customer Support

    We just released GenerateBlocks 1.7 which fixes the Query Loops pagination “bug” so that filter should apply to pagination too.

    Let me know

    #2542438
    Benny

    I thought so, thats why i build it with 1.7 after you mentioned it. Maybe you have a clue why its not working here –> http://app-gulgowski.2xaf1tm1wr-rz83ynk206d7.p.temp-site.link/thailand/

    #2542567
    David
    Staff
    Customer Support

    Did you add the Pagination block to the Query Loop block ? Its an option the query loop blocks toolbar.

    #2542576
    Benny

    I did, yes.

    #2542922
    David
    Staff
    Customer Support

    And silly question. I assume there is enough posts to trigger the need for pagination ?

    #2542933
    Benny

    Yes 😁

    If you want to, i can send you credentials and you can have a look into it.

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