ESSENTIAL GRID RELATED POSTS
ESSENTIAL GRID RELATED POSTS on Single blog Posts
/*ESSENTIAL GRID RELATED POSTS on Single blog Posts*/ add_filter('essgrid_query_caching', 'eg_stop_caching', 10, 2); add_filter('essgrid_get_posts', 'eg_mod_query', 10, 2); function eg_stop_caching($do_cache, $grid_id) { if($grid_id == X) return false; /*where X is the Grid ID*/ return true; } function eg_mod_query($query, $grid_id){ if($grid_id == X) { /*where X is the Grid ID*/ $categories = wp_get_post_categories(get_the_ID()); if(count($categories) > 0){ $posts_in_categories = new WP_Query(['category__in' => $categories]); if($posts_in_categories->found_posts > 1) { $query['category__in'] = $categories; } } $query['post__not_in'] = [get_the_ID()]; } return $query; }