The Grid Plugin - Exclude current post

I am using this code in my functions as I am trying to exclude the current post from the grid plugin.

function current_post_tgfilter($args) {
  
  $args['post__not_in'] = array (get_the_ID());

  return $args;

}
add_filter('tg_wp_query_args', 'current_post_tgfilter', 10, 2);

However, this doesn’t work as expected. Am I doing something wrong here?

many thanks,
Andrew

Hi Andrew,

Thanks for writing in! Could you also please try the following code (https://theme.co/apex/forum/t/excluding-the-current-post-from-the-grid-related-posts/41083/5?u=mldarshana) and see if that helps.

Make sure that you have setup your child theme correctly (https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57) and also make sure that you have activated your child theme from Appearance -> Themes section.

If you’re using a caching plugin, you will need to purge server cache as well as browser cache before testing (https://www.wpbeginner.com/beginners-guide/how-to-clear-your-cache-in-wordpress/).

Let us know how it goes.
Thanks!

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