• Resolved JeRetiens

    (@jeretiens)


    Hello there !

    How can I add the nofollow attribute on the links I’ve made on the images of the slider ?

    Thank you very much !

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    You can filter the attributes like this:

    add_filter('metaslider_flex_slider_anchor_attributes', function ($attributes) {
        $attributes['rel'] = 'nofollow';
        return $attributes;
    });

    Let me know if you have any questions

    Thread Starter JeRetiens

    (@jeretiens)

    Hello @kbat82 and thank you for your answer !

    Could you tell me in which file should I put this code ?

    Thanks a lot !

    Hi,

    Typically you would put this as an mu-plugin file inside the wp-content directory. So for example, create a file at wp-content/mu-plugins/metaslider-customizations.php then add the filter, like this:

    <?php
    
    add_filter('metaslider_flex_slider_anchor_attributes', function ($attributes) {
        $attributes['rel'] = 'nofollow';
        return $attributes;
    });

    You will have to access the server files via FTP or another means.

    Alternatively, you can add the filter directly to your theme’s functions.php file. This you can do from the Theme editor, but the risk is that if you update your theme, the filter could be deleted during the update process.

    • This reply was modified 4 years, 4 months ago by Kevin Batdorf.
    Thread Starter JeRetiens

    (@jeretiens)

    Thanks a lot ! I will do it neat with a file in the mu-plugins directory ??

    Your support rocks !!!

    Thread Starter JeRetiens

    (@jeretiens)

    Sorry to reopen this ticket… but it caused a blank page on my entire website ^^’

    So I was just wondering, if it’s not too much work for you, if it could be possible to add the option in the future update of the plugin ?

    In general options, we have a checkbox “open in a new window”, could you add also a “add nofollow” ?

    Thanks a lot !

    Hi,

    I don’t think it’s something that will be added, but did you get any errors on the server logs? Sometimes if you copy/paste quotes (“) the encoding gets messed up. It’s better if you can delete the quotes and type them by hand instead.

    Also, that function requires PHP 5.4 I believe

    Thread Starter JeRetiens

    (@jeretiens)

    Hello,

    Just reopening to tell I found the solution on Github, the code to add in functions.php is :

    /**
     * INSTALLATION: this code should be pasted into your theme's functions.php file.
     */
    function metaslider_nofollow($attributes, $slide, $slider_id) {
        $attributes['rel'] = "nofollow";
        return $attributes;
    }
    add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
    add_filter('metaslider_nivo_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
    add_filter('metaslider_responsive_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
    add_filter('metaslider_coin_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
    /* END metaslider no follow  */

    Cheers

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How can I add the nofollow link attribute ?’ is closed to new replies.