Disable Self-Pings in your WordPress Theme
A well-known tactic for SEO called “interlinking” is when you link to your own posts. In WordPress, pingbacks are the equivalent of interlinking, and are automatically enabled by default. This can start to get annoying after a while when you are referencing other blog posts often… WordPress will automatically create a new comment about the pingback of that post. These pingback comments will appear in the comments section of your posts, and can start clogging up your comment list with something that looks like spam to other potential commenters.
To disable self-pingbacks from your own website, simply add the following lines of code to your functions.php file:
add_action('pre_ping', 'disable_self_ping'); function disable_self_ping(&$links) { foreach ($links as $l => $link) if (0 === strpos($link, get_option('home'))) unset($links[$l]); }
Leave a Reply