Sometimes in WordPress when you want to query a particular page but don’t know it’s ID and know better than to rely on it’s title there is no way to really query it. For example if you had a contact page that used a custom template called, “contact-page-template.php” there is no internal function that does this for you.
WordPress stores the page template into a private custom field on each page that has a custom template assigned. Using meta queries, we can query pages by this custom value. The following function will allow you to query a page by it’s template and either return or echo an array of contents as well as support for a single key (you only want the title or url for example).