WordPress Tutorials 1 min read

How to Disable Self Pingbacks in WordPress

Published by Manuel Campos on September 24, 2022 • Updated on November 4, 2024

If you’ve ever linked to another post on your WordPress website, you’ve likely seen trackbacks or “self-pings” appear in the comments section.

While trackbacks can be helpful for linking between different sites, self-pings within your own site can clutter your comments section unnecessarily.

Thankfully, WordPress offers a simple way to prevent these internal pings.

Adding a small snippet can effectively stop self-pings. Here’s the code:

// prevent self-pings
function shapeSpace_prevent_self_pings(&$links) {
	$home = get_option('home');
	foreach ($links as $l => $link) {
		if (0 === strpos($link, $home)) unset($links[$l]);
	}
}
add_action('pre_ping', 'shapeSpace_prevent_self_pings');
Manuel Campos

Manuel Campos

I'm a WordPress enthusiast. I document my journey and provide actionable insights to help you navigate the ever-evolving world of WordPress."

Read Next

Support Honest Reviews

Help keep the reviews coming by using my recommended links.

May earn commission • No extra cost to you