Do you want to link WordPress post title to an External URL? Look no further, you have come to the right place. We will give the easiest ways to handle this issue.

Introduction

Sometimes, you will need to link your WordPress post title to external resources for any reason. For example, you can share a link with your readers instead of creating a whole post.

Moreover, adding an external link from the WordPress post title also allows your visitors to simply visit your website by clicking on your post/page. Thanks to this way, you can save a lot of time on building a post or generating navigation elements.

For this reason, in today’s blog, we will teach you how to link WordPress Post Title to an External URL quickly. Now, let’s go over the following sections.

How to link WordPress Post title to an External URL?

Page Links To plugin is a useful tool that allows you to make a WordPress post/page or custom post type link to a URL that you provide instead of its WordPress URL.

In advance of using this plugin, you need to install it.

Just go to Plugins > Add New from your WordPress dashboard menu. Then you can use the search bar feature to look for the “Page Links to” plugin. After that, simply click on the “Install Now” button and “Activate” it.

Link Wordpress Post Title

Once the plugin has been installed. Now you need to edit any existing post or start creating a new one.

In the post editor, let’s scroll down the screen, you will see the new “Page Links To” meta box.

Link Wordpress Post Title

Let’s select the ” A custom URL” option to add the URL that you want to add to the WordPress post title.

After that, don’t forget to click on the Publish/Update button to save your post.

Now, your post title will link to the custom URL that you provided.

Method 2: Using code snippets

This method requires you to install any additional plugin. However, you have to add code snippets to your WordPress site.

Simply add the following code to your theme’s functions.php file or a site-specific plugin.

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=='external_url') {
$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>';
}

This code will help you find a custom field that contains your custom URL. In the event that the post has the custom field, then it outputs the post title linked to your URL.

Next, you need to replace your theme’s default display of post title with this function. You can look for it in archives.php, content.php, category.php, and other templates. It will be similar to the following code.

<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>

Now, it is time to replace it with the code snippets below:

<?php print_post_title() ?>

In the next step, you need to add the external URL to the post. Similarly, you can edit any available post or click on the “Add New” button to create a new one.

On the post editor screen, let’s find the “custom fields” meta box.

If the custom fields meta box is not available below the editor area, you need to click on the “Screen Options” in the top right corner of the screen. Then, this will expand the menu with a list of options. You need to tick the checkbox next to the “Custom Fields” option.

Link Wordpress Post Title

After that, you can find the “Custom fields” meta box displayed below the post editor. Let’s click on “Enter New“.

Link Wordpress Post Title To External Url 4 1

Then, under the “Name” field, you need to enter external_url and the URL you want to add to the post title in the “Value” field.

Link Wordpress Post Title To External Url 5

Now, you can Publish or Update your post. And of course, your post title will be linked to the URL that you entered in the custom field.

Next time, once you need to add a link, simply select the external_url custom field from the drop-down menu. Then provide your external link in the “Value” field.

The final thoughts

All methods that we have just shown completely are easy to use and effective. Hopefully, this article can help you easily link WordPress post title to an external URL. In that case, you have any questions or queries, let us know by leaving a comment below.

Furthermore, you can drop by our free WordPress Themes website to explore many gorgeous, modern themes and templates. If you want to build a professional website, don’t miss our website.

5/5 - (1 vote)
Lt Digital Team (Content &Amp; Marketing)
Latest posts by LT Digital Team (Content & Marketing) (see all)
Summer Sale Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now
🎉 Black Friday & Cyber Monday sale! Grab 50% Off for everything on today, don't miss it. Coupon code: BFCM50 Redeem Now