mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Introduce get_page_template_slug( $id = null ) to return a page's template (like "showcase.php"). Returns false if post ID is not a page, and an empty string for the default page template. Use the function across core. props billerickson for initial patch. fixes #18750.
git-svn-id: https://develop.svn.wordpress.org/trunk@20075 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -225,20 +225,17 @@ function get_front_page_template() {
|
||||
*/
|
||||
function get_page_template() {
|
||||
$id = get_queried_object_id();
|
||||
$template = get_post_meta($id, '_wp_page_template', true);
|
||||
$template = get_page_template_slug();
|
||||
$pagename = get_query_var('pagename');
|
||||
|
||||
if ( !$pagename && $id > 0 ) {
|
||||
if ( ! $pagename && $id ) {
|
||||
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
|
||||
$post = get_queried_object();
|
||||
$pagename = $post->post_name;
|
||||
}
|
||||
|
||||
if ( 'default' == $template )
|
||||
$template = '';
|
||||
|
||||
$templates = array();
|
||||
if ( !empty($template) && !validate_file($template) )
|
||||
if ( $template && 0 === validate_file( $template ) )
|
||||
$templates[] = $template;
|
||||
if ( $pagename )
|
||||
$templates[] = "page-$pagename.php";
|
||||
|
||||
Reference in New Issue
Block a user