When you publish a post that contains a link to another post on your own site, WordPress’s pingback system fires and sends a pingback notification to that linked post. The linked post then receives a pingback comment in its moderation queue, a notification that your own site linked to itself. This is a pointless round-trip: you already know your own site linked to itself, and the pingback clutters your comment moderation with entries you’ll never approve or that get auto-approved as spam noise.
The Code
Add this to your functions.php or a site-specific plugin. It’s one of the most concise and effective debloat snippets available, a single function that filters out your own domain from the list of URLs to ping before pingbacks are sent.
How It Works
The pre_ping action fires with a reference to the array of links found in the post content that are candidates for pingback. The snippet loops through this array and removes any URL that starts with your site’s home URL. WordPress then processes the remaining links, external sites that legitimately should receive pingbacks, and skips your own domain entirely.
The & before $links in the function signature is important, it passes the array by reference, meaning modifications to $links inside the function affect the original array that WordPress will process. Without the reference, the changes would be discarded.
External Pingbacks Still Work
This snippet only removes self-referential pings. If you link to another site that supports pingbacks, that pingback still fires normally. The filter is surgical, it targets only URLs that begin with your own home URL and leaves all external links untouched.
If You’ve Disabled Pingbacks Globally
If you’ve already disabled pingbacks and trackbacks site-wide through Settings → Discussion → unchecking “Allow link notifications from other blogs”, this snippet is redundant, no pings are sent at all. This snippet is most useful on sites where you want to keep pingbacks enabled for external links (to notify other sites when you cite them) but eliminate the noise of self-pings specifically.
add_action( 'pre_ping', function( &$links ) {
$home = home_url();
foreach ( $links as $key => $link ) {
if ( strpos( $link, $home ) === 0 ) {
unset( $links[ $key ] );
}
}
} );
