我正在使用Genesis Framework,然后使用子主题来创建框架。我可以为框架的子主题制作一个子主题吗?
答案 0 :(得分:4)
有趣的想法。我不知道,但显然,你可以。来自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.