我使用创世纪框架,然后使用一个子主题作为创世框架。我能把一个儿童主题变成框架的儿童主题吗?
发布于 2014-05-13 01:02:07
有趣的想法。我不知道,但很显然,你可以。来自http://www.wp-code.com/wordpress-snippets/wordpress-grandchildren-themes/
而不是编辑子主题,创建一个外孙主题。它非常类似于创建一个子主题,除非你是通过插件来实现的。您可以将您的自定义函数添加到插件中,就像在functions.php中一样(但是请记住,您的插件将被调用得比functions.php早得多,因此您需要确保插件中的任何代码只在触发操作时运行)。
/*
Plugin Name: Grandchild Theme
Plugin URI: http://www.wp-code.com/
Description: A WordPress Grandchild Theme (as a plugin)
Author: Mark Barnes
Version: 0.1
Author URI: http://www.wp-code.com/
*/
// These two lines ensure that your CSS is loaded alongside the parent or child theme's CSS
add_action('wp_head', 'wpc_theme_add_headers', 0);
add_action('init', 'wpc_theme_add_css');
// This filter replaces a complete file from the parent theme or child theme with your file (in this case the archive page).
// Whenever the archive is requested, it will use YOUR archive.php instead of that of the parent or child theme.
add_filter ('archive_template', create_function ('', 'return plugin_dir_path(__FILE__)."archive.php";'));
function wpc_theme_add_headers () {
wp_enqueue_style('grandchild_style');
}
function wpc_theme_add_css() {
$timestamp = @filemtime(plugin_dir_path(__FILE__).'/style.css');
wp_register_style ('grandchild_style', plugins_url('style.css', __FILE__).'', array(), $timestamp);
}
// In the rest of your plugin, add your normal actions and filters, just as you would in functions.php in a child theme.https://stackoverflow.com/questions/23620624
复制相似问题