Theme Development

Make Content Clickable In WordPress

Wordpress has a great feature I've just discovered which allows you to convert plain text into links for URLs or email addresses.

If your content has URLs in the content but you haven't add the link you can use this WordPress function to convert all plain text URLs to be links.

The WordPress function you need to use is called make_clickable().

This accepts one parameter which should be a string of the text you want to convert.

It will be able to convert a number of different types of links:

  • URLs - Adds link to the URL
  • www - Adds link to the www link
  • FTP - Adds link to the ftp link
  • Email - Adds a link with a mailto around the email address

$string = "This is a long text that contains some links like and .";
echo make_clickable($string); 
Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial