How to disable/remove self pingback

Hi to all,
I would like to ask for assistance on how to disable/remove pingback in all of my internal links. Every time I link my post to another post I always got a pingback in the comment below my post which is sometimes annoying or looks like a bug.

Thank you for all your assistance.

Hi there,

Thanks for writing in!
There is no such option in the theme to avoid this. You can check this article for help.

Thanks

Hi Basanta,

Thanks for the reply. I tried the script given on the link but there was an error that states like this:

function no_self_ping( &$links ) {
$home = get_option( ‘home’ );
foreach ( $links as $1 => $link )
if (0 === strpos( $link, $home ) )
unset($links[$1]);
}
add_action( ‘pre_ping’, ‘no_self_ping’ );

Your PHP code changes were rolled back due to an error on line 242 of file wp-content/themes/x/functions.php. Please fix and try saving again.

syntax error, unexpected ‘1’ (T_LNUMBER), expecting variable (T_VARIABLE) or ‘{’ or ‘$’

Could you please help me with the error here? I’m no programmer.

Hello @jqtroy,

Thanks for asking. :slight_smile:

I added the code shared in the WPBeginner in my local setup and it seems to be working fine. I would also suggest you to add the code in child theme. The issue with adding code in parent theme files is that when you update the theme, changes will get overridden with new files. To avoid that problem, please install Child theme. After that add the code in child theme function.php file. You can use following resource to download and setup Child theme.

  1. Download Child theme from here: https://theme.co/apex/child-themes
  2. Child theme setup guide:

Thanks.

Hi Prasant,
Thank you for assistance. Quite busy and been out of my pc right now. I’ll give it a try as soon as i’m back in my desk.

Thank you. Get back to us with the result.

Hi Basanta, Prasant,Christopher.Amirian,

I already downloaded, installed and activated the X child theme. The inserted the code provided by wpbeginner.com and it has no bugs or error anymore. Thank you for the help. I refresh my site and even waited for a day to see any changes or updates in my site. Today, upon visiting my site I still see the ping back below every post in the comment. What should I do now to get rid of the pingback?

Again thank you for the assistance.

Hello There,

Please provide us access to your site so that we can take a closer look.
To do this, you can create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

By the way, have you tried the plugin method?
​
Thank you.

Hi,

Existing Feedbacks will not be removed.

The code added from wpbeginner will stop it from adding more.

You can delete feedbacks from comments section.

See screenshot

Thanks

Hi Paul,

Thank you for the prompt reply.

You’re welcome! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.