This is interesting, with years experience working with WordPress, I’ve never dealt with this kind of issue. I searched the codex, and found get_page_by_path is the ideal solution instead of directly create query to database.
[php]get_page_by_path( $page_path, $output, $post_type );[/php]
To get a page ID simply add the slug to the function
[php]
// Returns Object page ID
$page_id = grain_get_url_by_slug(‘slug’);
[/php]
I creates a function to simplify the usage
function get_url_by_slug($slug) { $page_url_id = get_page_by_path( $slug ); $page_url_link = get_permalink($page_url_id); return $page_url_link; }
And use it in real life
<p> <a href="<?php echo get_url_by_slug('services'); ?> "> What can we do for you? </a> </p>