I want to add a rel=”nofollow” to all the links in my wordpress posts and I want to be able to have a list of links that won’t get the nofollow.
I have been trying a lot, but I can’t get it done right, because I really can’t understand regex very well.
So I have the string $text and I want to replace a href=”url”> with a href=”url” rel=”nofollow”> unless the href matches some specific domains.
Say you added a class to links you don’t want to be followed…
This will add
nofollow
to all links except ones with a class defined above.