WordPress Function to Make Links Clickable

Apparently I’ve been doing things the hard way in my WordPress-related coding. I’ve been using regular expressions to turn URLs into clickable links, when WordPress already has a built-in formatting function to do just that.

Meet make_clickable(). All you have to do is pass a string to it, and it will return the string, but with any web URLs, email addresses or FTP URLs turned into HTML links.

$text = 'This is a cool link: http://www.webmaster-source.com';
echo make_clickable($text);

Will return This is a cool link: http://www.webmaster-source.com. Easy enough, and certainly a more efficient method than writing your own function to do it.

  • http://www.infomaroto.com/blog/ Vinicius Viana

    but don't forget the SEO ;D

  • http://intensedebate.com/people/thefrosty thefrosty

    Very neat trick!

  • http://fujiinstaxminifilm.com/ Andy Eaton

    thanks for the help, been searching ages for an answer

  • http://www.getdownloads.org Movies

    thx mate good trick!

  • Pingback: Free classified ads worldwide