The Grid load more button is duplicating posts

Hi,
I am using 2 separate ‘The Grid’ grids to display blog posts on the same page. The first one shows 3 posts and the second shows the rest of my posts - www.foresttech.events.
I am using the code in my Child theme functions to offset the second grid by 3.
This works, however, now the ‘load more’ button on the second grid is loading a duplicate of the posts already loaded. Its fine if I set it to load all the posts, but if any limit is set the “load more” or “load on scroll” functions only duplicate the posts already loaded. It also didn’t work when I tried the suggested code on https://theme.co/apex/forums/topic/help-with-the-grid-loading-posts/ (it sounds like the exact same issue though).
This is the code I have in functions.php:

function my_query_args($query_args, $grid_name) {

    if ($grid_name == 'Blog Posts B') {
        // all query parameters can be modified (https://codex.wordpress.org/Class_Reference/WP_Query)
        $query_args['offset'] = 3;
    }
    
    return $query_args;
    
}

add_filter('tg_wp_query_args', 'my_query_args', 10, 2);

Hey @Innovatek,

According to the WordPress WP Query documentation at https://codex.wordpress.org/Class_Reference/WP_Query, the

posts_per_page (int) - number of post to show per page (available since Version 2.1, replaced showposts parameter). Use ‘posts_per_page’=>-1 to show all posts (the ‘offset’ parameter is ignored with a -1 value). Set the ‘paged’ parameter if pagination is off after using this parameter. Note: if the query is in a feed, wordpress overwrites this parameter with the stored ‘posts_per_rss’ option. To reimpose the limit, try using the ‘post_limits’ filter, or filter ‘pre_option_posts_per_rss’ and return -1

offset (int) - number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround). The ‘offset’ parameter is ignored when ‘posts_per_page’=>-1 (show all posts) is used.

There is currently no way to use pagination including AJAX pagination without problems. You will need to use “Load All Posts” or manually exclude posts.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.