Home » , , , » How to link your post title to external links

How to link your post title to external links

First open your functions.php file and add this code to it.


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>';
}

These code must be placed in php tags

Now open your index.php file and find this code

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

Finally replace it with this code

<?php print_post_title(); ?>

Done
If You Like product from here Click Here free product informationGoogle Android PC Tablet

0 comments:

Post a Comment

 
Support : Creating Website | SEO Template | Free Template
Copyright © 2011. Free Wordpress Theme And Templates For You - All Rights Reserved
Proudly powered by Blogger