• Resolved franksysgfx

    (@franksysgfx)


    I recently asked and verified that it didn’t work in wordpress multisite in general, but if I activate web by web yes, and I’m happy about that, just one question, I ASKED CHATGPT and he gave me this code: you could take a look at it and mention me if you see it any problem ? Thanks friend ??

    function add_nofollow_to_external_links_except_domain($content) {
    $excluded_domain = ‘domain-exclude.com’;

    $pattern = '/<a(.*?)href=["\'](https?:\/\/(?!'. preg_quote($excluded_domain) .'))(.*?)["\'](.*?)>/i';
    $replacement = '<a$1href="$2$3"$4 rel="nofollow">';
    $content = preg_replace($pattern, $replacement, $content);
    
    return $content;

    }
    add_filter(‘the_content’, ‘add_nofollow_to_external_links_except_domain’);

    • This topic was modified 1 year, 7 months ago by franksysgfx.
    • This topic was modified 1 year, 7 months ago by franksysgfx.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘hello’ is closed to new replies.