Skip to content

Instantly share code, notes, and snippets.

@indeedably
Last active September 5, 2018 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indeedably/8b493ca129ffd1131a489b9ff3c7036a to your computer and use it in GitHub Desktop.
Save indeedably/8b493ca129ffd1131a489b9ff3c7036a to your computer and use it in GitHub Desktop.
How disable Wordpress self pings.
/*
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