Get Permalink by Name
September 2nd, 2008If you have a post or a page and need the permalink for it there are serveral solutions. Here are one of them. I created a name to permalink converter.
Put the following code to the functions.php in your theme folder.
function wt_get_permalink_by_name($page_name)
{
global $post;
global $wpdb;
$pageid_name = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."'");
return get_permalink($pageid_name);
}
Call the function like this in your theme:
<a href="<?php echo wt_get_permalink_by_name('about'); ?>">About</a>
To get all new functions/template tags, install my plugin WP Extra Template Tags.
This may have changed since you posted it, but it should be post_title to work.
Exactly what I was lookign for. Thanks
How to get Permalink of a page in-side the Plugin function?
Wow!! It’s getting better and better. Keep it up man.,