Support » Plugin: Gutenberg Blocks – Ultimate Addons for Gutenberg » Offset in Post Grid and Post Masonry Block

  • Resolved ThBunte

    (@thbunte)


    Will there be an Offset for Post Layout Block.
    These will enhance the block to extremly better layout options.
    F.e. to place in an page first an Post Layout Block with 1 Post only and greater image, then a second Post Layout Block as grid with 3 Post and offset of 1 (to not double the first post) and maybe then a list of 10 other Posts?
    Your blocks are so well constructed and feature-rich that it is surprising that the offset feature, which almost all competitors have, is not available.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @thbunte,

    Unfortunately, as of now, there is no such option to set offset in the Post Grid and the Post Masonry blocks.

    However, this can be achieved using the filter code.

    For the Post Grid block:

    To apply different filters for different Post Grid Blocks you need to add unique classes to each of the blocks from the Advanced Tab of Post Grid Block.

    Please refer to this screenshot.

    After that, you can just add “if” condition for each of the Blocks.

    For example: If you want to add different Offsets to different blocks you can use the following code for the Post Grid block:

    function filter_post_query( $query_args, $attributes) {
        // Unique class name added from Advanced tab for Post Grid Block.
        if ( 'my-post-grid-class' == $attributes['className'] ) {
       
            $query_args['offset'] = 3;
        }
    
        // Unique class name added from Advanced tab for Post Grid Block.
        if ( 'second-my-post-grid-class' == $attributes['className'] ) {
       
            $query_args['offset'] = 4;
        }
        //And So on....
        return $query_args;
       }
    add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );

    For the Post Masonry block:

    Similarly, just like the above step, you have to first add unique classes to each of the blocks from the Advanced Tab of Post Masonry Block.

    After that again, you can just add “if” condition for each of the Blocks.

    For example: If you want to add different Offsets to different blocks you can use the following code for Post Masonry block:

    function filter_post_query( $query_args, $attributes) {
        // Unique class name added from Advanced tab for Post Masonry Block.
        if ( 'my-post-masonry-class' == $attributes['className'] ) {
       
            $query_args['offset'] = 3;
        }
    
        // Unique class name added from Advanced tab for Post Grid Block.
        if ( 'second-my-post-masonry-class' == $attributes['className'] ) {
       
            $query_args['offset'] = 4;
        }
        //And So on....
        return $query_args;
       }
    add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );

    I hope this helps.

    Regards,
    Sweta

    Thread Starter ThBunte

    (@thbunte)

    tnx for these Information, it works well.
    But I think for not so experienced WordPress users placing a code snippet in functions.php is not the ideal way.
    In this case it would make much more sense to integrate the offset function directly into the blocks for post grid and post masonry.

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @thbunte,

    I will surely convey your feedback to our concerned developers. We are always keen to listen to our customers and to receive their feedback. This is the best way to improve our products and services and maintain our client’s satisfaction. 🙂

    I’ll put forward your thought about this to our team and if feasible we will try to improve the scenario in our future updates.

    If you have any further queries, please don’t hesitate to contact us.

    Regards,
    Sweta

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Offset in Post Grid and Post Masonry Block’ is closed to new replies.