In WordPress to get any URL, we can use the get_permalink() function using a post ID or a post object.
One cool feature is to get a page link using its slug or title using other helper functions. Identify an URL by its slug is useful if you don’t know the correct ID; this can happen in a lot of cases like if your development environment differs from the live one.
The two needed helper , in this case, are get_page_by_path() and get_page_by_title(). Both functions came back with a post object, the first using the slug while the second using the title.
get_permalink( get_page_by_path( 'contact' ) ); get_permalink( get_page_by_title( 'Contact' ) );