Support » Plugin: Responsive Slider by MetaSlider - Slider and Carousel Plugin for WordPress » How can I add the nofollow link attribute ?

  • 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)
  • Plugin Contributor kbatdorf

    (@kbat82)

    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

    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 !

    Plugin Contributor kbatdorf

    (@kbat82)

    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 2 months ago by kbatdorf.
    JeRetiens

    (@jeretiens)

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

    Your support rocks !!!

    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 !

    Plugin Contributor kbatdorf

    (@kbat82)

    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

    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)
  • You must be logged in to reply to this topic.