Post Grid: Exclude Current Post

0
Post Grid: Exclude Current Post 1
Sam
May 27, 2016 10:26 PM 2 Answers General
Member Since May 2016
Subscribed Subscribe Not subscribe
Flag(0)

Hi,
I am using the premium post grid plugin with the "Divi" them from elegant themes. I cannot get the feed to load when it is on a post page, as I have added the shortcode in the Divi page builder.
Can I somehow set the post grid to exclude the current post that it is displayed on. I cannot use the exclude post feature as I want to use the same shortcode post grid on all future blog posts as I will just duplicate the page and don't want to have to create individual post grids.
I am working on localhost unfortunately so not link at the moment, I hope this makes sense I you can provide some help.
Thanks

0 Subscribers
Submit Answer
Please login to submit answer.
2 Answers
Sort By:
Best Answer
0
Post Grid: Exclude Current Post 2
PickPlugins
May 28, 2016
Flag(0)

please replace previous code

function post_grid_filter_query_args_extra($query_args){
if(is_singular( 'post' )){

$current_post_id = get_the_ID();

$extra_query = array (

'post__not_in' => array($current_post_id),

);

return array_merge($query_args, $extra_query);

}
else{
return $query_args;

}

}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');

 

Sign in to Reply
Replying as Submit
Best Answer
0
Post Grid: Exclude Current Post 2
PickPlugins
May 27, 2016
Flag(0)

Welcome to our forum,

Please download the latest version ( 3.0.28) of Post grid from here http://pickplugins.com/my-account/ and reinstall.

I have update the plugin to add filter hook for query argument so you can add your own argument by filter hook. like bellow code will solve your issue. you can add your logical to fine tune the query arguments.

function post_grid_filter_query_args_extra($query_args){
$current_post_id = get_the_ID();

$extra_query = array (

'post__not_in' => array($current_post_id),

);

return array_merge($query_args, $extra_query);
}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');

Please let me know for more help

Post Grid: Exclude Current Post 4
Flag (0)
0

Sorry i didn’t noticed your lats reply , are you there ?
Regards

Post Grid: Exclude Current Post 4
Flag (0)
0

OK try:

ID: 666 250 572
Pass: wg593u

Post Grid: Exclude Current Post 4
Flag (0)
0

If you already install version 3.0.28 , i hope you don’t need to do anything. can you please send me TeamViewer access , Regards

4+ more comments. Sign in to Reply
Replying as Submit

One comment

  1. Something like this, but I wouldn’t know where to enter it and if it will work?

    $args= array( ‘post__not_in’ => array($this_post) );

Comments are closed.