Created
December 8, 2017 12:00
-
-
Save steve10287/b8fcfba6c95dccb0a2bdf368de8a8f58 to your computer and use it in GitHub Desktop.
Wordpress get page template url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_template_page_url($template_name) { | |
$page_permalink = ""; | |
$page = get_pages( array( | |
'meta_key' => '_wp_page_template', | |
'meta_value' => $template_name | |
) ); | |
if ( ! empty( $page ) && 0 < count( $page ) ) : | |
$translate_page = get_post($page[0]->ID); | |
$page_permalink = get_permalink( $translate_page ) ; | |
endif; | |
return $page_permalink; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment