Last active
September 5, 2018 19:51
-
-
Save indeedably/8b493ca129ffd1131a489b9ff3c7036a to your computer and use it in GitHub Desktop.
How disable Wordpress self pings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
By default Wordpress will ping itself with each internal link. | |
This is annoying and a tad inefficient. To disable: | |
1. Open your Wordpress theme's functions.php file located in /wp-content/themes/[YOUR THEME]/ | |
2. Paste the code snippet below into your functions.php | |
3. Save to have the changes take effect. | |
*/ | |
function disable_self_pings( &$links ) { | |
foreach ( $links as $i => $link ) | |
if ( 0 === strpos( $link, get_option( 'home' ) ) ) | |
unset($links[$i]); | |
} | |
add_action( 'pre_ping', 'disable_self_pings' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment