Question from Margaret B.: I have a very active WordPress blog and I publish anywhere from 7 to 10 new posts every day.
I do a lot of inter-linking with my posts and every time I link to one of my own posts it generates a trackback. I don’t like that because it clutters up the comments stream.
I know I could simply disable trackbacks altogether but I’d rather only disable them for links to my own posts. Is there a way to do that?
Rick’s answer: Yes Margaret, there are a couple of ways to disable trackbacks on your own inter-linked posts while still allowing them for links to external sites.
If you don’t want to bother with editing your blog’s theme files you can disable self trackbacks by installing a plugin. Just follow the steps below:
1 – Log in to your WordPress Dashboard.
2 – Click Plugins>Add New.
3 – Type No Self Pings into the search box. A plugin by that name should pop pop.
4 – Click the Install Now button and then activate the plugin when prompted.
That’s the easy way to disable self-trackbacks. But there’s a better way if you don’t mind getting your hands dirty by editing one of your theme files.
You can also disable self-trackbacks by adding a short snippet of code to your theme’s functions.php file. This is the preferred method because it won’t add an additional plugin to your WordPress installation.
Important: If you decide to go this route, do so carefully because editing any of your blog’s theme files isn’t a risk-free endeavor.
One simple misplaced character can wreak all kinds of havoc with your blog. In fact, one simple error can prevent your blog from loading at all! Again, be careful when editing your blog’s theme files!
This is why I always recommend that you back up your blog’s files before making any changes to your theme files. Failure to do so can potentially cause a lot of grief.
Now that we have that dire warning out of the way, follow the steps below to disable self-trackbacks by adding a snippet of code to your theme’s functions.php file:
1 – Log in to your WordPress Dashboard.
2 – Click Appearance>Editor.
3 – Select the theme that’s currently active on your blog from the drop-down menu. If you are using a parent theme and child theme setup be sure to select the child theme.
4 – Double-click Themes Functions (functions.php).
5 – Copy and paste the following code snippet at the bottom of the functions.php file:
function no_self_ping( &$links ) {
$home = get_option( ‘home’ );
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, $home ) )
unset($links[$l]);
}
add_action( ‘pre_ping’, ‘no_self_ping’ );
6 – Click Update File.
That’s all there is to it Margaret. Regardless of which method you used, you shouldn’t be receiving any more trackbacks on your own blog posts!
Update from Margaret: Thanks Rick. I’m a big chicken when it comes to editing my blog files so I went with the plugin. I appreciate all your help!
Bonus tip: This post explains why I recommend using VaultPress to back up your WordPress blog.
Do you have a tech question of your own for Rick? Click here and send it in!
Like this post? If so, I invite you to share it with your friends. Just click one of the handy social media sharing buttons below.