Disable self-ping / self-trackback in WordPress without Plugin

16 Aug

Disable self-ping / self-trackback in WordPress without Plugin

Context: Disable self-ping / self-trackback in WordPress without Plugin
Solution: This trick prevents WordPress from self-ping, which happens if you cross-link pages or posts of your own website.

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

Bydr.code.skm

I am backend developer with passion in Web Application development using latest technologies like Laravel, PHP7, React, ECMAScript 6 and WordPress. I prefer spending time analyzing big data with Apache Spark. Apart from that, I do photography.