2014-05-12 85 views

回答

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. 
相關問題