Hi, today I’m going to give you a small PHP snippet that saves a lot of time when you work over your WordPress website. Here is what I’m talking about :
One of the well known SEO technic is linking your posts between them with in content text links. This helps you to better position your posts for certain keywords on Google. Also, it helps to keep your visitors on the site and drive some more traffic towards the older posts. Here is a good blog post about this on DIYthemes blog.
While WordPress gives you the easiest way ever to create links to your posts and pages within the text editor, when you link to your own content and your Ping option is enabled – you get notification via email to approve the trackback for the almost each link you do towards your website. This is what I call annoying…
How to fix it?
There is a really easy solution for you if you would like to disable self pinging but still notify external websites that you have linked to them. Here is the PHP code to paste into your functions.php file :
(those who use Thesis Framework, paste the code into your
custom_functions.phpfile, those who don’t – why not visiting Thesis Framework site and see what it can offer you?)
/* REMOVE SELF PINGING */ function remove_self_pinging(&$links,&$pung) { $self = get_option('siteurl'); foreach ($links as $link => $data) { if (false !== strpos($link,$self)) unset($links[$link]); } } add_action('pre_ping','remove_self_pinging',0,2); /* END REMOVE SELF PINGING */ |
How it works?
Once the code is placed into your theme, it is hooked to the pre_ping hook and receives an array of links before WordPress send any pings. So the code checks if the array contains the links pointing to the site domain and filters them out returning (by reference) only the external links. Simple and very useful.
stay tuned,
serge










{ 8 comments }
Hey Serge,
That’s a really great post…simple and very easy to use. And it saves on a plug-in…
Thanks!
you welcome. BTW how is it going?
Pretty good!! You still looking for writers for the site?
sure, are you interested?
Absolutely! If I recall, you mentioned on Twitter that PHP knowledge is not required?
Exactly, I will provide you with php snippets and/or plugins to review
Hi Serge,
How/where to implement this in T2?
I would like to spare the plugin, I use for the same
Regards,
as far as the thesis 2 is concerned it should be done either with a box (not really handy for this) or by adding the code to the custom.php file of the current skin.