Voici comment modifier un thème WordPress sans toucher au thème d’origine, en utilisant des fichiers copiés dans une sauvegarde (sous la forme d’un thème enfant).
- Pour repérer facilement le thème enfant utilisé, créez un nouveau dossier dans le répertoire « wp-content/themes » en combinant le nom du thème. (Ex. : si le thème d’origine est « twentyfifteen », créez le dossier « twentyfifteen-child ».)
- Copiez le fichier « style.css » du thème d’origine dans le dossier du thème enfant, puis modifiez « Theme Name » et « Themplate » comme ci-dessous.
[php]/*
Theme Name: Twenty Fifteen Child
Theme URI: https://wordpress.org/themes/twentyfifteen/
Template: twentyfifteen
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen’s simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer.
Version: 1.5
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready
Text Domain: twentyfifteenTemplate: twntyfifteen
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you’ve learned with others.
*/
[/php] - Dans le dossier du thème enfant, créez un fichier « functions.php » avec le code suivant.
[php]
<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
}
?>
[/php] - Copiez le fichier « screenshot.png » du thème d’origine dans le dossier du thème enfant.
- Copiez dans le dossier du thème enfant les fichiers du thème d’origine que vous souhaitez modifier, puis utilisez les versions modifiées.
(Référence : http://codex.wordpress.org/Child_Themes)




