How to make turn URLs into clickable links in the_content()

The P2 theme has a nice feature built-in: the ability to turn URLs into clickable links on the fly. It does this by using a WordPress built-in function called make_clickable().

Here’s how we can use this function to make this feature available to any theme.

The above code, once inserted into your child theme’s functions.php file, will take the_content(), pass it to the make_clickable() function, and then return it before it’s printed on the screen.

The advantage of using it this way is that no content in the database is modified, and it’s easy to remove this feature when it’s not needed anymore. Feel free to add conditions depending on categories or other factors (you could check if the string “http” is present in the_content(), or only do this with .com endings, etc).

Learn more about this function here: https://codex.wordpress.org/Function_Reference/make_clickable

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!