Hello Support team,
how can I add the nofollow attribute to external links in buttons?
Using a nofollow plugin does not work because only the links from the p links are set to nofollow.
Thank you
Hey Andreas_BS,
If you want to place the no-follow only on external links, please turn on the custom CSS field for Advanced Layout Builder elements – http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/
Then add this custom class (rel-nofollow) to buttons you would like to have rel=’nofollow’ – http://i.imgur.com/KOaCgrv.png
and go to Appearance > Editor and open Functions.php file and add following code:
function custom_class_rel(){
?>
<script>
jQuery(window).load(function(){
jQuery('.rel-nofollow a').attr('rel','nofollow');
});
</script>
<?php
}
add_action('wp_footer', 'custom_class_rel');
If this doesn’t work please try this instead:
function custom_class_rel(){
?>
<script>
jQuery(window).load(function(){
jQuery( '.rel-nofollow' ).each(function() {
jQuery( this ).find( 'a' ).attr('rel','nofollow');
});
});
</script>
<?php
}
add_action('wp_footer', 'custom_class_rel');
Best regards,
Mike
Hi Mike,
thank you for sharing the solution. It works great.
Greetings
Andreas
Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.
For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)
Best regards,
Mike