我正在使用Post templates
插件。但它非常过时。
我正在Warning: Illegal offset type
在这条线上
$templates = $themes[$theme][\'Template Files\'];
这是我的全部功能代码。
function get_post_templates() {
$themes = wp_get_themes();
$theme = wp_get_theme();
$templates = $themes[$theme][\'Template Files\'];
$post_templates = array();
$base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
foreach ((array)$templates as $template) {
$template = WP_CONTENT_DIR . str_replace(WP_CONTENT_DIR, \'\', $template);
$basename = str_replace($base, \'\', $template);
// don\'t allow template files in subdirectories
if (false !== strpos($basename, \'/\'))
continue;
$template_data = implode(\'\', file( $template ));
$name = \'\';
if (preg_match( \'|Single Post Template:(.*)$|mi\', $template_data, $name))
$name = _cleanup_header_comment($name[1]);
if (!empty($name)) {
if(basename($template) != basename(__FILE__))
$post_templates[trim($name)] = $basename;
}
}
return $post_templates;
}
有人能告诉我怎么修吗?