Self-pingbacks are a feature in WordPress that automatically creates a pingback from your own website to itself when you link to one of your own posts or pages.

While this can be useful for some users, it can also clutter up the comment section and create unnecessary notifications.

Here’s how to disable self-pingbacks in WordPress using PHP Snippet:

  • Open the functions.php file of your WordPress theme. This file can be found in the theme’s folder on your website.
  • Add the following code at the end of the file:
/**
* @snippet Disable Self-Pingbacks in WordPress
* @source https://www.wptechnic.com/?p=8520
* @compatible WP 6.1.1
*/
function disable_self_pingbacks( &$links ) {
foreach ( $links as $l => $link ) {
if ( 0 === strpos( $link, get_option( 'home' ) ) ) {
unset( $links[$l] );
}}}
add_action( 'pre_ping', 'disable_self_pingbacks' );
  • Alternatively, you can also use a plugin to add this PHP snippet to your website.
  • Save the changes to the functions.php file.
disable self pingbacks in wordpress

Once this code is added to your functions.php file, self-pingbacks will be disabled on your WordPress website.

Did this code work for your website? Or you’re having difficulties? Either way, let me know by leaving a comment below right now.

Avatar for Muhammad Tamzid
Author

Muhammad Tamzid, the founder of WPTechnic, is a WordPress Enthusiast with a passion to help beginners learning WordPress. Also managing WPrevival, a 24/7 WordPress Website Development, Maintenance & Security Service company.

Write A Comment