Exclude Current Post

Exclude the current Post from being included in the Grid. This is useful for “Related Posts” grids.

Let’s say you have a blog, and each post from your blog also contains a grid.  And the items for this grid represent all your blog posts.  If you want to exclude the current post from this grid, you can add the following PHP snippet to your theme’s “functions.php” file.

add_filter(‘essgrid_query_caching’, ‘eg_disable_chache’, 10, 2);
add_filter(‘essgrid_get_posts’, ‘eg_mod_posts’, 10, 2);
function eg_mod_posts($query, $grid_id){
	if($grid_id == 1){
		$exclude_id = get_queried_object_id();
		$query[‘post__not_in’] = array( $exclude_id );
	return $query;
function eg_disable_chache($do_cache, $grid_id) {
	if( $grid_id == 1 ) {
		return false;

In the PHP snippet, for the "grid_id == 1" parts, this will check to make sure the functionality is only applied to your specific grid.

To get the ID for your grid, visit the plugin’s main admin page where your grids are listed:

Exclude Current Post

The Author


Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!

[tp_popular title="Popular Grids" regex="(grids|template_library)" count=3]


Join over 25.000 others on the Essential Grid and Slider Revolution email list to get access to the latest news and exclusive content.