I know we have get_permalink() in WordPress to get permalink by id of specific page. So this post is only alternative how to get the permalink by name, slug or title.
1. Get Page ID by name, slug or title
<?php function rh_get_page_id($name) { global $wpdb; // get page id using custom query $page_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ( post_name = '".$name."' or post_title = '".$name."' ) and post_status = 'publish' and post_type='page' "); return $page_id; } ?>
2. Get Page Permalink by name, slug or title
<?php function rh_get_page_permalink($name) { $page_id = rh_get_pageid($name); return get_permalink($page_id); } ?>
3. How To Use
<?php // get by title echo rh_get_page_permalink('Your Page Name'); // get by name or slug echo rh_get_page_permalink('your-page-name'); ?>
Enjoy.. I hope it useful and works for you Image may be NSFW.
Clik here to view.
http://codex.wordpress.org/Function_Reference/get_permalinkget
The post WordPress : Get page permalink by name, slug or title outside loop appeared first on MySandbox.