Hi there!
As already mentioned <a href="https://wordpress.org/support/topic/current-post-is-not-excluded/" target="_blank" rel="noopener">here</a> I\'m having issues with the related posts plugin. I\'m using Content Views Pro to display posts and the related posts plugin in the sidebar via shortcode. I would expect the current post not to show in that list, but it\'s there. I also tried adding this to my functions.php:
<pre>add_action(\'related_post_main\', \'remove_related_posts\', 2);
function remove_related_posts(){
if(is_singular(array(\'post\'))){
<strong>$excluded_posts = get_the_ID();</strong>
$post_id = get_the_ID();
if(in_array($post_id, $excluded_posts)){
remove_action(\'related_post_main\' ,\'related_post_main_title\');
remove_action(\'related_post_main\' ,\'related_post_main_post_loop\');
}
}
}</pre>
which should remove the current post, right? Am I missing something else?
Best regards,
Matthias
Welcome to our forum.
have you checked my reply on wp.org?
https://wordpress.org/support/topic/current-post-is-not-excluded/
Regards