首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否有可能在Wordpress中创建一个儿童主题的子主题

是否有可能在Wordpress中创建一个儿童主题的子主题
EN

Stack Overflow用户
提问于 2014-05-12 23:37:03
回答 1查看 1K关注 0票数 2

我使用创世纪框架,然后使用一个子主题作为创世框架。我能把一个儿童主题变成框架的儿童主题吗?

EN

回答 1

Stack Overflow用户

发布于 2014-05-13 01:02:07

有趣的想法。我不知道,但很显然,你可以。来自http://www.wp-code.com/wordpress-snippets/wordpress-grandchildren-themes/

而不是编辑子主题,创建一个外孙主题。它非常类似于创建一个子主题,除非你是通过插件来实现的。您可以将您的自定义函数添加到插件中,就像在functions.php中一样(但是请记住,您的插件将被调用得比functions.php早得多,因此您需要确保插件中的任何代码只在触发操作时运行)。

代码语言:javascript
复制
/*
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.
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23620624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档