Do you want to disable self pings to your WordPress blog? While there’s probably a plugin for this, we have created a quick code snippet that you can use to disable self pings with pre_ping
hook in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
function no_self_ping( &$links ) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action( 'pre_ping', 'no_self_ping' );
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 15 best content marketing tools and plugins and how to set up download tracking in WordPress with Google Analytics.
this doesn’t work, error:
Fatal error: Cannot redeclare no_self_ping()
Hi That error means you have the function no_self_ping in your functions.php already.