Make URLs within posts clickable

Did you know that WordPress has a function ‘make_clickable’ which converts plain text URLs to HTML links? It converts URI, www, ftp, and email addresses to clickable hyperlinks and also helps by fixing links within links.

To make use of this function in the most effective manner, edit your theme’s functions.php file and add the following line:

1
add_filter('the_content', 'make_clickable');

The above code will automatically make all links clickable in your post content. If you want the returned content to be used some place else,

1
2
3
$theContent = make_clickable(get_the_content( ) );
// Then, echo it wherever you wish to display the content
echo $theContent;

Source: Codex

Posted by

Deepak Thomas is a guy who hearts wordpress. If you're having trouble with wordpress, tweet it with @thinkdj and he'll try to solve your queries for a box of chocolates.

Leave a Reply

Required fields are marked *.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>