不使用插件只需要一段简洁的代码就可以实现,WordPress子页面自动调用父页面的模板。
function wodepress_use_parent_template() { global $post; $curr_tmp = get_post_meta($post->ID, '_wp_page_template', true); //获取页面模板 if($post->post_parent){ $parent_tmp = get_post_meta($post->post_parent, '_wp_page_template', true); //如果有父页面,获取父页面模板 update_post_meta($post->ID, '_wp_page_template', $parent_tmp, $curr_tmp); //设置子页面的模板为父页面的模板 } } add_action('save_post','wodepress_use_parent_template'); 将上面这段代码加到functions.php文件中,就可以以非插件的方法实现,非常简单实用。 原文 https://www.wowsoho.com/news/4953.html