Wordpress Banner

TUTORIAL: Turn off WordPress ping backs on own website

I’ve had the trouble of own ping backs myself. My recent comments is full with self ping backs.

In this blog post I assume you have a Child theme. If not please refer to this blog post first.

  1. Open up your child theme directory and create a new file called functions.php.
  2. If you already have this file in your child-theme directory then please open it.
  3. Add the following snippet of code to your functions.php; and make sure you change the ‘twenty_fifteen’ names to your child-theme name.
<?php 
//Import parent styles the right way and add other stylesheets if necessary.
function twenty_fifteen_child_styles() {
 wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'twenty_fifteen_child_styles' );
  • Test out if your website is still working as it should.
  • If it does please continue to add this piece of code to your functions.php:
//remove pings to self
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' );

Your functions.php should look something like this now:

<?php 
//Import parent styles the right way and add other stylesheets if necessary.
function YOUR_THEME_NAME_styles() {
 wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'YOUR_THEME_NAME_styles' );


//remove pings to self
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' );

?>

I’ve actually turned mine off just now ;-). For more help please contact me or comment below.

Published by

Bas

My name is Bas Wijdenes and I'm working full time as a services engineer at Wortell. In my free time I like to write tutorials about computer problems I encounter on a daily basis. The main reason I started my blog is, because I wanted to work on my English vocabulary. If you've encountered a computer problem you can't get your head around, please do not hesitate to contact me.

Leave a Reply

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