Performance PHP Beginner

Stop Sending Pingbacks When You Publish

Stop WordPress contacting every site you link to and pinging update services each time you publish, which speeds up publishing.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 7 lines
// Don't run outgoing pings (pingbacks, trackbacks and update services).
add_action( 'init', function (): void {
	remove_action( 'do_pings', 'do_all_pings', 10 );
} );

// Untick "Attempt to notify any blogs linked to from the post".
add_filter( 'pre_option_default_pingback_flag', '__return_zero' );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When you publish, WordPress contacts every site you linked to (pingbacks), and the services listed under Settings → Writing → Update Services. These requests slow down publishing and rarely do anything useful today.

How it works

Outgoing pings run through do_all_pings(), hooked to the do_pings event that WordPress schedules after publishing. Removing it stops pingbacks, trackbacks and update service pings.

The option filter also unticks “Attempt to notify any blogs linked to from the post” in Settings → Discussion, so new posts don’t queue pings in the first place.

Things to watch

  • This only stops pings your site sends. To stop receiving them, use the “Disable Pingbacks but Keep XML-RPC” snippet.
  • Enclosures, which add media links to podcast feeds, are also handled by the ping task. If you run a podcast from WordPress, don’t use this snippet.

How to test it

Settings → Discussion should show “Attempt to notify any blogs linked to from the post” unticked. Publishing a post with external links should no longer leave _pingme entries in its post meta.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only