Is there a way that I can remove links in posts via my functions.php file. Basically I don't want anyone to be able to go outside of the blog posts that are viewed. I have hundreds of posts so I obviously can't go through all of them and remove them manually. Or could I use javascript?
Thanks so much.
Updated: The jQuery below is great. Does anyone know if there is a way I can do it thru php in my functions.php file? If, for whatever ridiculous reason, someone has JS disabled is why I ask.
Thanks!
You can strip out the links on the fly using a regular expression -
This would need to go in your theme wherever you print the_content. Untested.
You could use JavaScript, but you're not going to be able to stop people leaving if they want to.
Something like this may work, although I haven't tested and it was written off-hand:
With the jQuery library, this should replace all
<a>
tags with what was in between them.So
<a href="http://www.google.co.uk/">Google</a>
should become justGoogle
.