2014-05-12 4 views

Répondre

4

Idée intéressante. Je ne savais pas, mais apparemment, vous pouvez. À partir de http://www.wp-code.com/wordpress-snippets/wordpress-grandchildren-themes/

Au lieu de modifier le thème enfant, créez un thème petit-enfant. C'est très similaire à la création d'un thème enfant, sauf que vous le faites via un plugin. Vous ajoutez vos fonctions personnalisées au plugin, comme vous le feriez normalement dans dans functions.php (mais rappelez-vous que votre plugin s'appellera beaucoup plus tôt que functions.php, donc vous devrez vous assurer que tout code dans votre plugin ne s'exécute que lorsqu'une action est déclenchée).

/* 
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. 
Questions connexes