• Resolved miko7

    (@miko7)


    Hi,
    Is it possible to exclude certain posts by ID from the category in the Post Grid?
    I want to exclude certain posts from the grid. Thank you.

Viewing 1 replies (of 1 total)
  • Hello @miko7 ,

    You can exclude posts from the Post Grid block using the following filter.

    To do that please follow the following steps:-

    1] 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.
    2] You need to get the post IDs of the Pages or Posts you want to exclude.
    3] After that, you need to add the following filter in your child theme’s functions.php file.

    function 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', 'filter_post_query', 10, 2 );

    I hope that helps.

    Regards,
    Sweta

Viewing 1 replies (of 1 total)

The topic ‘Exclude Certain Post in Grid’ is closed to new replies.