How To Disable Self-Pingbacks In WordPress

Pingbacks are a questionable feature that are enabled by default in WordPress. If this feature is enabled by default, WordPress will create a ping-back for a post. It is essentially a thank you link from another website’s post to yours.

This is what is known as a self-ping-back. It is where WordPress creates a ping-back for one of your posts because you linked to it from another post. I personally find ping-backs to be nothing more than an annoyance. I always disable them on my website and client websites.

What is a Pingback?

Ping-backs allow websites to talk to one another saying “Hey!” “We linked to your post”. Then your website is like “Okay. Cool” and it goes to their website to make sure the link actually exists.

After your website checks that the link does exist, WordPress will add the ping-back as a comment. This is dumb because it provides no value to anyone, especially not your users. But what’s worse is when WordPress adds a ping-back from your own website.

How To Disable Self-Pingbacks

There are two easy ways to disable self-pingbacks. You can add a plugin or you can use a code snippet. I am going to show you both methods.

Use No Self Pings Plugin

First, you need to install and activate No Self Pings.The great thing is the basic functionality works outside of the box. All you have to do is turn the plugin on and it will turn off self ping-backs.

No Self Pings Discussion Settings

If you go to the Discussion Settings in WordPress, the plugin will also add a new box. You can paste website URL’s in this box. It will also disable pings from these URL’s.

With A Code Snippet

If you can add code to a child theme, then this is what I recommend. No need for unnecessary plugins. To disable self ping-backs in WordPress with code:

1. Add the following code to your child theme’s function.php file.
2. Or a site-specific plugin.

function sert_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', 'sert_no_self_ping' );

You can also disable ping-backs all together. This is done via the discussion settings. However, the above recommendations are for if you want ping-backs but not self ping-backs.

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

Leave a Comment