WordPress Snippets at WPcustoms

Get permalink by title or slug

You would normally grab a page link via its ID but in my case where I had a localhost install and an online install the ID was different. With this solution you are able to get the permalink for a page by its page title or page slug. Cool thing!

 * Snippet Name: Get permalink by title or slug
 * Snippet URL: http://www.wpcustoms.net/snippets/get-permalink-title-slug/
 get_permalink( get_page_by_path( 'map' ) )
get_permalink( get_page_by_title( 'Map' ) )
home_url( '/map/' )