By default, WordPress will allow you to show links only if you create ones by yourself. That means that you can create a link by selecting a word or the entire phrase, clicking on the “link” button and providing the URL if you’re working in the Visual Editor or you can write your own HTML code if you’re working in Text editor.
While this makes sense and makes creating links an easy task, if you write down the entire URL or an email address, WordPress would still recognize it as plain text.
If you tend to write full URLs, email addresses or FTP addresses on a daily basis, you are only going to lose time if you’re about to create those links manually. Instead, you can easily add filters which WordPress already recognizes as its own and thus tell your trustworthy web system to convert all that text into links automatically.
If you have decided to do so, here is how you can have your automatic links:
- Open functions.php file
- Copy and paste these filters:
- Save changes
add_filter('the_content', 'make_clickable'); add_filter('the_excerpt', 'make_clickable');
As you can see from the code itself, the same “make_clickable” filter is applied both to the content and the excerpt. You can, of course, choose where you want the automatic link conversion so feel free to choose only one of those if you want so.
If you are developing your own theme or customizing the existing one, you can avoid the option of adding the filter to the entire content or the excerpt and use the filter only in specific situations. In that case, you can use the filter in templates files:
<?php make_clickable( $text ) ?>
Here’s the example of using the function:
<?php $clickable = "This text contains a link to our website https://.firstsiteguide.com which will be automatically converted into a clickable link."; echo make_clickable( $clickable ); ?>
There you go. With the power of “make_clickable” function, you can easily convert links anywhere in your WordPress theme. While there are times and places where you don’t want your addresses automatically being clickable, sometimes this will save you precious time you would end up losing by manually going through all the text and linking it.
We hope this article will help you in developing your WP website. Don’t forget to check out the rest of our tutorials in order to improve your WordPress experience.