[wp-trac] [WordPress Trac] #41717: WP_Theme::get_post_templates() fails to read parent theme
WordPress Trac
noreply at wordpress.org
Wed Aug 23 20:16:23 UTC 2017
#41717: WP_Theme::get_post_templates() fails to read parent theme
--------------------------------------+-----------------------------
Reporter: JoelStransky | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.8.1
Severity: normal | Keywords:
Focuses: administration, template |
--------------------------------------+-----------------------------
Post Templates created in parent theme are not included when
get_post_templates() is used in a child theme.
Create a post template in a parent theme
{{{#!php
<?php
/**
* Template Name: Audio Topic
* Template Post Type: topic
*/
}}}
Then in child theme functions.php, call get_post_templates()
{{{#!php
<?php
add_action( 'admin_init', function() {
$log = wp_get_theme()->get_post_templates();
error_log( print_r( $log, true ) );
} );
}}}
You will only see post templates whose .php files exist within the child
theme root.
FIX:
In WP 4.8.1 wp-includes/class-wp-theme.php line 1045
(https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-
theme.php#L1006)
change:
{{{#!php
<?php
$files = (array) $this->get_files( 'php', 1 );
}}}
to
{{{#!php
<?php
$files = (array) $this->get_files( 'php', 1, true );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41717>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list