Tagged: external links
Hi Support
I want to add No Follow to external links. I’ve searched through previous threads and very confused.
Please can you explain it simply How do we add No Follow to external links?
Thanks, heaps
Dave
Hi Dave,
We have no setting for that, however, you can add this code in functions.php:
function nofollow_links() {
?>
<script>
(function ($) {
$(document).ready (function () {
var url = new RegExp(location.host);
$('#top .a').each(function () {
if( ! url.test($(this).attr('href')) ) {
$(this).attr('rel', 'nofollow');
}
});
});
}) (jQuery);
</script>
<?php
}
add_action ('wp_footer', 'nofollow_links');
this script should check all the links and if it’s an external link it will add the nofollow to the link.
Best regards,
Nikko