How to disable internal pingbacks in WordPress

You have probably noticed that when you link to a post on the same site you will get a pingback on the old post with a link to your new post. If you for whatever reason wants to get rid of those internal pingbacks, simply put the following code snippet in your functions.php. Note that you will still get pingbacks from other sites.

function disable_internal_pingbacks( &$links ) {
	$home = get_option( 'home' );
	foreach ( $links as $l => $link )
		if ( 0 === strpos( $link, $home ) )
			unset($links[$l]);
}

add_action( 'pre_ping', 'disable_internal_pingbacks' );

If you don’t like writing or adding code to your functions.php, you can instead install the No Self Pings plugin from WordPress plugin directory.

About Fredrik Malmgren

Fredrik Malmgren is an entrepreneur, project manager and developer specialized in WordPress. Read more about me or get in contact with me. You can also find me on Twitter. (@fredrikmalmgren).
This entry was posted in Tutorials, WordPress and tagged , , , . Bookmark the permalink.

2 Responses to How to disable internal pingbacks in WordPress

  1. Pingback: Tweets that mention How to disable internal pingbacks in WordPress | Fredrik Malmgren -- Topsy.com

  2. Pingback: About Pingback disabling, great plugins for preventive measures and the “Superpuperdomain.com” Wordpress Hack | Blogger's Weekly

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>