How To Create Link To External Resources In WordPress Without Plugin ?

The first thing to do is open your functions.php file and
paste in the following code:-

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=='url1' || $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>';
}

Once that’s done,open index.php file and replace the standard code
for printing titles.

<h2><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?
></a></h2>

… with a call to our newly created print_post_title() function:

<?php print_post_title() ?>

Now, pointing one of in posts’ titles somewhere other than own blog, just scroll down in post editor and create or select a custom key called url1 or title_url or url_title and put the external URL in the value box.

Total Page Visits: 12882 - Today Page Visits: 7

Leave a Reply