{"id":1204,"date":"2023-10-14T13:47:07","date_gmt":"2023-10-14T13:47:07","guid":{"rendered":"https:\/\/wpconsults.com\/?p=1204"},"modified":"2023-12-31T05:38:56","modified_gmt":"2023-12-31T05:38:56","slug":"comment-creer-un-theme-enfant-wordpress-2","status":"publish","type":"post","link":"https:\/\/www.wpconsults.com\/fr\/comment-creer-un-theme-enfant-wordpress-2\/","title":{"rendered":"Comment cr\u00e9er un th\u00e8me enfant pour WordPress"},"content":{"rendered":"\n<p>When it comes to customizing your WordPress website, creating a child theme is a smart move. Learn how to create for WordPress child theme &#8211;  It allows you to make changes to your theme without losing any of the customizations when the theme updates. <\/p>\n\n\n\n<p>In this blog post, we will guide you through the process of creating a child theme manually and using a plugin for your WordPress website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-a-child-theme\">What is a Child Theme?<\/h2>\n\n\n\n<p>A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. It allows you to make modifications to your website&#8217;s design and functionality without affecting the original theme files. This is particularly useful when you want to customize your website while keeping the ability to update the parent theme.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-creating-a-child-theme-manually-method-1\">Creating a Child Theme Manually (Method 1)<\/h2>\n\n\n\n<p>Now, let&#8217;s dive into the step-by-step process of creating a child theme:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new folder in the &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">themes<\/mark>&#8216; directory of your WordPress installation. You can name it anything you like, but it&#8217;s best to use a name that reflects the parent theme.<\/li>\n\n\n\n<li>In the newly created folder, create a new file named &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">style.css<\/mark>&#8216;. This file will contain the CSS code for your child theme.<\/li>\n\n\n\n<li>In the &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">style.css<\/mark>&#8216; file, add the following code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* \nTheme Name: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">My Child Theme <\/mark>\nTemplate: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">parent-theme <\/mark>\n*\/<\/code><\/pre>\n\n\n\n<p>Replace &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">My Child Theme<\/mark>&#8216; with the name of your child theme and &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">parent-theme<\/mark>&#8216; with the directory name of the parent theme.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Create a new file in the child theme folder named <strong>&#8216;<\/strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">functions.php<\/mark>&#8216;. This file will contain the PHP code for your child theme.<\/li>\n\n\n\n<li>In the &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">functions.php<\/mark>&#8216; file, add the following code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nadd_action( 'wp_enqueue_scripts', '<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">my_child_theme<\/mark>_enqueue_styles' );\n\nfunction <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">my_child_theme<\/mark>_enqueue_styles() {\n    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '\/style.css' );\n}\n\n?&gt;<\/code><\/pre>\n\n\n\n<p>This code enqueues the parent theme&#8217;s stylesheet. Replace <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">&#8220;my_child_theme&#8221;<\/mark> with the actual name you have given to your child theme. You can also add your own custom CSS and PHP code to modify the theme&#8217;s functionality.<\/p>\n\n\n\n<p class=\"has-theme-palette-6-color has-text-color has-small-font-size\" style=\"letter-spacing:0px\"><em>Note: The only required file for your child theme is style.css. However, for most users, the primary purpose of creating a child theme is to modify or add functions. To achieve this, you need to create a functions.php file. This file can remain empty and does not serve as a template file, so there&#8217;s no need to copy it from the parent theme.<\/em> <em>If do do not need to add any functions you can simply skip it.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-activate-the-child-theme\">Activate the Child Theme<\/h2>\n\n\n\n<p>Once you have created the child theme, it&#8217;s time to activate it:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Login to your WordPress admin dashboard.<\/li>\n\n\n\n<li>Navigate to &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Appearance&#8217; &gt; &#8216;Themes<\/mark>&#8216;.<\/li>\n\n\n\n<li>You will see your newly created child theme listed. Click on the <strong>&#8216;<\/strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Activate<\/mark>&#8216; button to activate it.<\/li>\n<\/ol>\n\n\n\n<p>That&#8217;s it.<\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b, .wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b[data-kb-block=\"kb-adv-heading1204_1ab052-0b\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b[data-kb-block=\"kb-adv-heading1204_1ab052-0b\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading1204_1ab052-0b[data-kb-block=\"kb-adv-heading1204_1ab052-0b\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading1204_1ab052-0b wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading1204_1ab052-0b\">Creating a Child Theme Using a Plugin<\/h2>\n\n\n\n<p>While creating a child theme manually requires some coding knowledge, there is an easier way to do it &#8211; by using a plugin.<\/p>\n\n\n\n<p>In this part o the blog post, I will guide you through the process of creating a child theme using a plugin, step by step.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install and Activate the Child Theme Plugin<\/h3>\n\n\n\n<p>The first thing you need to do is install and activate a child theme plugin. There are several plugins available in the WordPress repository, but for this tutorial, we will be using the &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Child Theme Configurator<\/mark>&#8216; plugin.<\/p>\n\n\n\n<p>Go to your WordPress dashboard, navigate to &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Plugins&#8217; &gt; &#8216;Add New<\/mark>&#8216;, search for &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Child Theme Configurator<\/mark>&#8216;, and click on &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Install Now<\/mark>&#8216; and then &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Activate<\/mark>&#8216;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Configure the Child Theme<\/h3>\n\n\n\n<p>Once the plugin is activated, you will see a new menu item called <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">&#8216;Child Themes&#8217; in your WordPress dashboard. <\/mark>Click on it to configure your child theme.<\/p>\n\n\n\n<p>On the &#8216;Child Themes&#8217; page, you will find a list of your installed themes. Select the parent theme for which you want to create a child theme and click on <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">&#8216;Analyze&#8217;<\/mark>. The plugin will analyze the parent theme and create a child theme for you.<\/p>\n\n\n\n<p>After the analysis is complete, you will be redirected to the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">&#8216;Edit Child Theme&#8217;<\/mark> page. Here, you can customize various aspects of your child theme, such as the name, description, author, and version.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Customize the Child Theme<\/h3>\n\n\n\n<p>Now that your child theme is created, it&#8217;s time to start customizing it. You can make changes to the CSS, functions, and template files of your child theme without affecting the parent theme.<\/p>\n\n\n\n<p>To make CSS changes, go to &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Appearance&#8217; &gt; &#8216;Customize<\/mark>&#8216; in your WordPress dashboard. You will see a new section called &#8216;Child Theme&#8217; where you can add your custom CSS code.<\/p>\n\n\n\n<p>If you want to make changes to the functions.php file, go to &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Appearance&#8217; &gt; &#8216;Editor<\/mark>&#8216; and select your child theme from the dropdown menu. You can then add your custom PHP code to the functions.php file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Activate the Child Theme<\/h3>\n\n\n\n<p>Once you are done customizing your child theme, it&#8217;s time to activate it. Go to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">&#8216;Appearance&#8217; &gt; &#8216;Themes&#8217;<\/mark> in your WordPress dashboard and you will see your child theme listed there. Simply click on the &#8216;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-theme-palette-1-color\">Activate<\/mark>&#8216; button to activate your child theme.<\/p>\n\n\n\n<p>That&#8217;s it! You have successfully created a child theme using a plugin. Now you can make changes to your theme without worrying about losing your customizations.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"h-need-a-professional-website\">Need a Professional Website? <\/h2>\n\n\n\n<p class=\"has-text-align-center\">If you need professional assistance in creating websites or landing pages, we are here to help. Contact us today to discuss your requirements and get started on your project.<\/p>\n\n\n<style>.wp-block-kadence-advancedbtn.kb-btns1204_502f72-81{gap:var(--global-kb-gap-xs, 0.5rem );justify-content:center;align-items:center;}.kt-btns1204_502f72-81 .kt-button{font-weight:normal;font-style:normal;}.kt-btns1204_502f72-81 .kt-btn-wrap-0{margin-right:5px;}.wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button{color:#555555;border-color:#555555;}.wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button:hover, .wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button:focus{color:#ffffff;border-color:#444444;}.wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button::before{display:none;}.wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button:hover, .wp-block-kadence-advancedbtn.kt-btns1204_502f72-81 .kt-btn-wrap-0 .kt-button:focus{background:#444444;}<\/style>\n<div class=\"wp-block-kadence-advancedbtn kb-buttons-wrap kb-btns1204_502f72-81\"><style>ul.menu .wp-block-kadence-advancedbtn .kb-btn1204_b4e96c-db.kb-button{width:initial;}<\/style><a class=\"kb-button kt-button button kb-btn1204_b4e96c-db kt-btn-size-standard kt-btn-width-type-auto kb-btn-global-fill  kt-btn-has-text-true kt-btn-has-svg-false  wp-block-kadence-singlebtn\" href=\"https:\/\/wpconsults.com\/contact\/\" rel=\"nofollow noopener\" target=\"_blank\"><span class=\"kt-btn-inner-text\">Start a Conversation<\/span><\/a>\n\n<style>ul.menu .wp-block-kadence-advancedbtn .kb-btn1204_97cf32-f7.kb-button{width:initial;}<\/style><a class=\"kb-button kt-button button kb-btn1204_97cf32-f7 kt-btn-size-standard kt-btn-width-type-auto kb-btn-global-fill  kt-btn-has-text-true kt-btn-has-svg-false  wp-block-kadence-singlebtn\" href=\"https:\/\/wpconsults.com\/schedule-a-meeting\/\" rel=\"nofollow noopener\" target=\"_blank\"><span class=\"kt-btn-inner-text\">Schedule a meeting<\/span><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Lorsqu'il s'agit de personnaliser votre site web WordPress, il est judicieux de cr\u00e9er un th\u00e8me enfant. Apprenez \u00e0 cr\u00e9er un th\u00e8me enfant WordPress - Il vous permet d'apporter des modifications \u00e0 votre th\u00e8me sans perdre vos personnalisations lorsque le th\u00e8me est mis \u00e0 jour. Dans cet article de blog, nous vous guiderons \u00e0 travers le processus...<\/p>","protected":false},"author":1,"featured_media":3246,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[64],"class_list":["post-1204","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-tips-tutorials","tag-without-plugin-series"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.wpconsults.com\/wp-content\/uploads\/2024\/05\/WpConsults-Default-post-thumbnail-jpg.webp?fit=1280%2C720&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pboFy3-jq","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/posts\/1204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/comments?post=1204"}],"version-history":[{"count":0,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/posts\/1204\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/media\/3246"}],"wp:attachment":[{"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/media?parent=1204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/categories?post=1204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wpconsults.com\/fr\/wp-json\/wp\/v2\/tags?post=1204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}