divPress

Discover WordPress. Get acquainted from level-one about the nuances of developing for Wordpress. Learn to code like a Pro using advanced WordPress coding.

Do subscribe to get regular updates via RSS.

Make URLs within posts clickable

Automatically make unlinked URLs within wordpress 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

Was this post useful? Share on Twitter or Facebook and spread the love.   

Related Posts

Now What?

Leave a Reply

Allowed Tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>