Hi @birdhousedigital,
Thanks for getting in touch with us.
You can achieve your desired goal by using uagb_post_query_args_grid filter. For more information, you can check this guide: https://wpspectra.com/docs/filters-actions-for-post/
Please try and let me know how it goes.
Have a nice day!
Thank you. I was trying the following but it doesn’t seem to work?
function filter_post_query( $query_args, $attributes) {
if ( ‘media-post-grid’ == $attributes[‘className’] ) {
$query_args[‘post__not_in’] = array( 1, 89 );
}
return $query_args;
}
add_filter( ‘uagb_post_query_args_grid’, ‘filter_post_query’, 10, 2 );
Hi @birdhousedigital,
It seems you are removing specific posts from the query, however, in your first message you had mentioned to exclude specific category. Please let me know if you have changed your mind. And please also note that, you have to change the className from the above code to the class name that you added in the block from the block settings.
Looking forward to hearing from you.
Have a nice day!
Oh yes I see! I got mixed up. Finally got it working with the following
function filter_post_query( $query_args, $attributes) {
// Unique class name added from Advanced tab for Post Grid.
if ( ‘media-post-grid’ == $attributes[‘className’] ) {
// 1 is the category id you want to exclude.
$query_args[‘category__not_in’] = array( 1,89 );
}
return $query_args;
}
add_filter( ‘uagb_post_query_args_grid’, ‘filter_post_query’, 10, 2 );
Thanks for your help!
Hi @birdhousedigital,
Thanks for letting us know.
I’m glad it works out for you.
Please feel free to open a new thread if you face any other issue.
Have a nice day!