Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #652328

    We have a bunch of outgoing links in the partner/logo element. We need to add the attribute rel=”nofollow” to all links.
    I tried looking in the module but cant find any way to add html code like rel=”nofollow”.

    #652397

    Hey belinger!

    function add_custom_script(){
    ?>
    <script>
    $( document ).ready(function()
    { $('body > a').attr("rel", "nofollow");
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Add that code to your functions.php file and replace the body > a with the class you want it to have.
    Do let us know if it works for you as needed.

    Regards,
    Basilis

    #652680

    Thanks for your reply. I have tried to figure out what to replace body > a with. I cant get it working. I provided link and further details in private area:

    #654020

    Hi,

    Please try this code instead:

    // custom script
    add_action('wp_footer', 'ava_custom_script');
    function ava_custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
    	function a() {
    		$('#top .avia-logo-element-container .slide-image').each(function() {
    			$(this).attr('rel', 'nofollow');
    		});
    	}
    
    	a();
    })(jQuery);
    </script>
    <?php
    }

    Best regards,
    Ismael

    #822214

    Hi Ismael,

    I tried this solution to make my logo link nofollow, and it appears in the code but still follow for Nofollow checker tools.
    I share you on Private Content the custom code I added to the functions.php files and how it looks like on the Chrome console.

    Thank you for your help.

    BR,

    #822692

    Hi PaddleSurfEs,

    This line has to target the link, not the span and the function a() has to be :)

    
    function a() {
        $('#top .logo a').attr('rel', 'nofollow');
    }
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #823004

    Hi Victoria,

    Thank you for your answer but I´m such a newbie and I´m lost :( I share you in private content the website URL and logo span code. Should you please adapt the custom code to make it works with my logo?

    Thanks in advance for your help.

    Florian

    #824041

    Hi Florian,

    The no-follow has to be on the link (https://www.w3schools.com/tags/att_a_rel.asp), it is there now, in the correct location.

    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.