X

Disable self pings with pre_ping hook

Adding this snippet to the functions.php of your wordpress theme will disable self pings to your blog.



Code Snippet:


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' );

Comments  Leave a Reply

  1. this doesn’t work, error:
    Fatal error: Cannot redeclare no_self_ping()

    1. Hi That error means you have the function no_self_ping in your functions.php already.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!