How to link post title to external URL in WordPress

Achin Verma

Reviewed by:
On December 8, 2014
Last modified:January 21, 2016


There are many times when you want to link WordPress post title to external URL.Learn How to link post title to external URL in WordPress with two easy ways

How to link WordPress post title to an external URL

While browsing web i came across some website where they have linked post title to external URL. When we click the post title then we are redirected to the external link. One of the example can be, they have post image and tittle and when you click on it then you are redirected to the external page.

By default WordPress does not allow you to do this kind of thing, this is due to the reason that WordPress is a blogging platform and they like you to create your own post. But you can change that, I’ll tell you two ways to do it, one is with the change of code and second is with the use of plugin.

link post title to external URL with change of code

In order to link post title to external URL you have to make few changes to the code and use the custom fields to perform the task.

Now at first you have to go to Dashboard»Appearance»Editor, now you have to click on file named functions.php. Now you have to paste the code given below.

<pre>function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);

if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='url_ext' || $pkey=='title_url' || $pkey=='url_title') {
$post_val = get_post_custom_values($pkey);
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
} else {
$link = $perm;
echo '<h2><a href="'.$link.'" rel="bookmark" title="'.$title.'">'.$title.'</a></h2>';


After placing this code hit save. Now you have to find the file named index.php and click on it. Find the code below

<h2>php the_permalink() ?>" rel="bookmark"><!--?php the_title(); ?--></h2>

Replace the above code with this code given below.

<?php print_post_title() ?>

Now hit the save button..

After this when you hit the save button then you have to scroll to the section called Custom Fields. there you have to find the field with the name url_ext,title_url,url_title. and add the external link to the field. You can even add a description and publish the post.

With these codes you will have a Custom field by which you can make your post title directed towards an external URL. If you don’t add this field then the post title will function normally as it should, so you don’t have to worry about changing the setting permanently.

Link post title to external URL using plugin

This is my favorite way to link post title to external URL, using a plugin is easy as well as a clean way to get the job done. why i prefer plugin is due to the reason that sooner or later we all have to change the blog design, when we change the theme of the blog, it changes all the theme files like functions.php, index.php, single.php, etc, So you have to do all the coding again, but with a plugin you are not bounded to this, you can change the theme without having to worry about anything and plugin will keep on doing its work.

For making a link post title to external URL there is a plugin available for free in WordPress plugin repository.

It’s called page link to.

This is a popular plugin to link post title to external URL, with this you have to just select an option that whether the post is a normal WordPress post or you can select an alternate URL where the post should redirect to.


You can even make the external link to open in new browser window, this option is given in a check box which can be easily accessed.

These are the two ways by which you can link WordPress post title to an external link. You can choose any one you like either code it or use a plugin. we would like to hear that which way do you like, use the comment section below to drop us comment.

Further read:

Achin Verma

I'm Achin Verma writer and creator of zdidit. you can follow me on facebook ,

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *