How to automatically nofollow a set domains? (I seem to have half of the answer)

Instead of the linked option you could just go with something using jQuery. Try adding something like this to your primary theme or plugin javascript file. (Usually something like main.js.) jQuery( document ).ready( function($) { $( ‘a[href^=”https://google.com”], a[href^=”https://yahoo.com”]’ ).each( function() { $( this ).attr( ‘rel’, ‘nofollow’ ); } ); } ); For any additional URLs … Read more

How can I modify all existing tags while keeping the urls themselves?

I solved the issue with help from this answer: https://wordpress.stackexchange.com/a/159570/176615 // add nofollow to Amazon function add_nofollow_content($content) { $content = preg_replace_callback( ‘/<a[^>]*href=[“|\’]([^”|\’]*)[“|\’][^>]*>([^<]*)<\/a>/i’, function($m) { if (strpos($m[1], “amzn.to”) !== false) return ‘<a href=”‘.$m[1].'” rel=”nofollow noopener” target=”_blank”>’.$m[2].'</a>’; else return ‘<a href=”‘.$m[1].'” rel=”noopener” target=”_blank”>’.$m[2].'</a>’; }, $content); return $content; } add_filter(‘the_content’, ‘add_nofollow_content’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)