Essential Grid as Related Posts/Pages

Hello I have a question about “Essential Grid”. I want to use it to display “related pages/posts” and so I have selected all the related pages, but it shows the page it is on also.

Has anyone used this as a way to show related posts/pages, EXCLUDE the current page and show previous and next in the list?

Here is the page I have it on:
https://pinpointpromo.staging.wpengine.com/our-…/dawn-event/ (all the way at the bottom)

Attached are screens of my settings

I also tried this and added the code to my functions.php in my child theme and it still displayed the current page
https://www.themepunch.com/faq/exclude-current-post

I know what I need is possible but I am just not seeing it, thanks all!

Hello There,

Thanks for writing in! The code should have worked unless you haven’t changed the ID of the your GRID.

if($grid_id == 1){

The number 1 should be replaced with the exact Grid ID or else the code will fail to exclude the current post.

Please let us know how it goes.

Hi this is the exact code I’m using and the current post still shows:

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 == 21){

$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 == 21 ) {
return false;
}

}

What does the 10,2 control in the 2 top lines?

Hi There,

10 and 2 on the top two lines represents priority and arguments for the add_filter function. See it here: https://developer.wordpress.org/reference/functions/add_filter/

Your setup seems correct. Would you mind sharing site wordpress and FTP credentials on a secure note so we double check?

Hello - how do I send this info privately?

Hi there,

You can add it in a Secure Note which is the lock/key icon that is under your response.

Thank you.

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