• Resolved backinblack

    (@backinblack)


    Is it possible to have two different post grids on a page that show posts from all categories, but don’t show the first few posts in each one? As an example, I have a post grid with all categories, followed by post grid that only shows posts from one category, and then another post grid that shows all categories again. I’d like to show the last four posts in the first ‘all categories’ grid, and continue with 5-8 in the other ‘all category’ post grid.

    All in all I’m really enjoying your plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @backinblack ,

    To show your first Post Grid with all categories containing first four posts, you have to select the Posts Per page as 4 from here.

    And for the second post grid, you can use the following filter.

    => To apply different filters for a specific block you need to add a unique class to the block from the Advanced Tab of Post Grid Block.

    => You need to get the post IDs of the Pages or Posts you want to exclude.

    => After that, you need to add the following filter in your child theme’s functions.php file.

    function specific_post_filter_post_query( $query_args, $attributes) {
     // Unique class name added from Advanced tab for Post Grid.
     if ( 'my-post-grid-class' == $attributes['className'] ) {
     // 123 and 456 is the post id you want to exclude.
     $query_args['post__not_in'] = array( 123,456 );
     }
     return $query_args;
    }
    add_filter( 'uagb_post_query_args_grid', 'specific_post_filter_post_query', 10, 2 );

    I hope that helps. Let me know how it goes.

    Regards,
    Sweta

    Hello @backinblack ,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Duplicate posts on posts page’ is closed to new replies.