Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1059839

    Please, help!
    1. Can be possible to make a link (going out of my website) unfollow in text and how?
    2. Is a link to website owner (the person who leaves a comment) in the comments section, is unfollow?
    Thank you so much in advance!

    #1060055

    Hey Gala,

    1. Are you referring on a link to an external site to open in new tab or window? instead of opening in the same tab?
    2. I’m not really sure what you mean with unfollow, can you give us more context?

    Best regards,
    Nikko

    #1060583

    Hello Nikko,
    1. So sorry:) I mean nofollow. I am looking how to make an external link to other websites nofollow.
    How to make external site link open in a new tab I know this option, it is easy to find. Love Enfold!
    Thank you so much! Gala

    #1060711

    Hi Gala,

    Try adding this php code in functions.php:

    add_filter('the_content', 'my_nofollow');
    add_filter('the_excerpt', 'my_nofollow');
     
    function my_nofollow($content) {
        return preg_replace_callback('/<a[^>]+/', 'my_nofollow_callback', $content);
    }
     
    function my_nofollow_callback($matches) {
        $link = $matches[0];
        $site_link = get_bloginfo('url');
     
        if (strpos($link, 'rel') === false) {
            $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link);
        } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) {
            $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link);
        }
        return $link;
    }

    Best regards,
    Nikko

    #1061126

    Hi Nikko,
    Thank you so much but I am not a big code person, so I need to learn more before use it. Thank you so much for your help! I really love Enfold!

    #1061801

    Hi Gala,

    Glad that we are able to help you :)
    Feel free to create a new thread if you need more assistance.
    Thanks for using Enfold and have a wonderful day ahead!

    Best regards,
    Nikko

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How To Make Link Unfollow? Please Help!’ is closed to new replies.