Hello Sebastian,
Thanks for the comment. You can get the id of the post from the post edit screen, while hovering on the “Edit” button or by simply editing it and fetching it from the URL address.
In the video I explained how to do it: https://www.youtube.com/watch?v=cv9BuKcfbhk
Let me know if it works.
Cheers!
Hi Gicolek,
thank you for your fast answer. Yes I know to exclude individually posts and how I finde the ID. But I need a dynamic solution. So that the current post that I visit not displays in the sidebar.
Thanks for your help!
Hey,
I thought you had this problem using a shortcode on a post.
This is unachievable without programming, you’d have to hook into “acf_rwp_query” and paste the code inside your functions.php file.
If you’re not comfortable with that I can code a sample for you on one of the default templates.
Cheers,
Rafal
Hi Rafal,
thanks for your help. I can only program a little, so if you could code me a php snippet for the function.php, that would be totally great!
Thank you
Sebastian
Alright. I’ll get back to you by the end of the week.
Cheers!
Hi Rafal,
do you found a solution?
Thank you again.
Greetings
Sebastian
Hello Sebastian,
Unfortunately not yet. I got a flu during the weekend and couldn’t have worked at all. I’ll get back to you ASAP, sorry for the delay.
Hello Sebastian,
Here’s the promised code for you:
add_filter( 'acf_rwp_query', 'wp_doin_exclude_current_post', 10, 1 );
function wp_doin_exclude_current_post($query_args) {
global $post;
if ( $post->ID ) {
if ( isset( $query_args['post__not_in'] ) ) {
$query_args['post__not_in'][] = $post->ID;
} else {
$query_args['post__not_in'] = array( $post->ID);
}
}
return $query_args;
}
You’ll need to put in the functions.php of your active theme. Let me know if it works for you 🙂
Cheers,
Rafal
Hi Rafal,
thank you very much. I’m a little bit busy and had just short time to test it, but it seems to work.
Big thank you again, very nice!!
Maybe you include it in your plugin, I think it is a important feature.
Greetings
Sebastian
Thanks Sebastian,
I will appreciate a review if possible 😛
I will think about it having it included if I get the others to ask for such a feature.
You were the first one I think.
Have a nice day!