How To Stop/Disable Self Pingback/Trackback On WordPress

We all know that Trackback and pingback are important to blogging but what is annoying is, getting self pingback to your blog when you link to an article in a post. though some people love it, but to me, it annoying and irritating. I thought this will be in wordpress core but i was anazed when i couldn’t find where to disable it on my dashboard.
If you share same plight with me, worry no more ‘cos there’s a solution to it.
There are three ways known to me to stop this menance:-

  1. Using A Plugin
  2. Adding Code Snippet In theme’s Function.php
  3. Using Relative URLs

    • Disabling Trackback Via Plugin
      If you don’t like doing coding, you can decide to make use of plugins.
      To disable trackbacks and pingback using a plugin, make use of either Disable Self Pingbacks 0r No Self Ping Plugin.
    • Adding Code To Theme’s Function.php file
      Am not a fan of using plugins, if you are like me, Add the below code to your theme’s function.php 

      
      /* No Self Pings by https://w3guy.com*/
      //Pass the variable by reference to the function, so the function can modify the variable.
      function no_self_ping (&$links) {
      $home = get_option( 'home' );
      foreach ( $links as $l => $link )
          //Find the position of the first occurrence of a substring in a string.
          //($a === $b) Identical operator. TRUE if $a is equal to $b, and they are of the same type.
          if ( 0 === strpos( $link, $home ) )
              //Unset the variable
              unset($links[$l]);
      }
      //Hooks the function to the specific action (pre_ping)
      add_action( 'pre_ping', 'no_self_ping' );
      
    • Relative URL For Linking
      This is very recommended. instead of using absolute URLs for linking, use relative URLs.
      Must Read Relative URL vs Absolute URL
Don’t miss out!
Subscribe to My Newsletter
Invalid email address