{"id":1487,"date":"2024-09-05T16:21:57","date_gmt":"2024-09-05T16:21:57","guid":{"rendered":"https:\/\/debugspot.com\/?p=1487"},"modified":"2024-09-10T07:45:21","modified_gmt":"2024-09-10T07:45:21","slug":"how-to-create-a-wordpress-child-theme","status":"publish","type":"post","link":"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/","title":{"rendered":"How to Create a WordPress Child Theme"},"content":{"rendered":"<p>To create a child theme in WordPress, follow these steps:<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Step_1_Create_a_New_Child_Theme_Folder\" >Step 1: Create a New Child Theme Folder<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Step_2_Create_a_stylecss_File\" >Step 2: Create a style.css File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Step_3_Create_a_functionsphp_File_for_Enqueuing_Styles\" >Step 3: Create a functions.php File (for Enqueuing Styles)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Step_4_Activate_the_Child_Theme\" >Step 4: Activate the Child Theme<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Step_5_Customize_Your_Child_Theme\" >Step 5: Customize Your Child Theme<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/debugspot.com\/blogs\/how-to-create-a-wordpress-child-theme\/#Why_Create_a_Child_Theme\" >Why Create a Child Theme?<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1 class=\"post-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Create_a_New_Child_Theme_Folder\"><\/span>Step 1: Create a New Child Theme Folder<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<ol>\n<li><strong>Access Your WordPress Files:<\/strong> Use an FTP client (like FileZilla) or access your hosting control panel (e.g., cPanel) to navigate to the WordPress directory.<\/li>\n<li><strong>Go to the Themes Directory:<\/strong> Open wp-content\/themes\/.<\/li>\n<li><strong>Create a New Folder:<\/strong> Inside the themes directory, create a new folder for your child theme. Name it appropriately, such as yourtheme-child, where &#8220;yourtheme&#8221; is the parent theme\u2019s name.<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Create_a_stylecss_File\"><\/span>Step 2: Create a style.css File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li><strong>Create a New style.css File:<\/strong> Inside the child theme folder, create a file named style.css.<\/li>\n<li><strong>Add the Required Header Information:<\/strong> Add the following code to the style.css file:\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">\r\n\/*\r\nTheme Name:   Your Theme Child\r\nTemplate:     yourtheme\r\nVersion:      1.0\r\n*\/\r\n<\/code><\/pre>\n<ul>\n<li><strong>Theme Name:<\/strong> Name of your child theme.<\/li>\n<li><strong>Template:<\/strong> The folder name of your parent theme (e.g., &#8220;yourtheme&#8221;).<\/li>\n<li><strong>Version:<\/strong> Version number of your child theme.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Create_a_functionsphp_File_for_Enqueuing_Styles\"><\/span>Step 3: Create a functions.php File (for Enqueuing Styles)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li><strong>Create a New<\/strong> functions.php <strong>File:<\/strong> Inside the child theme folder, create a file named functions.php.<\/li>\n<li><strong>Enqueue the Parent Theme\u2019s Stylesheet:<\/strong> Add the following code to your functions.php file:\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">\r\nfunction yourtheme_child_enqueue_styles() {\r\n    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '\/style.css' );\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'yourtheme_child_enqueue_styles' );\r\n<\/code><\/pre>\n<p>This ensures that the parent theme\u2019s stylesheet is loaded along with the child theme&#8217;s.<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Activate_the_Child_Theme\"><\/span>Step 4: Activate the Child Theme<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li><strong>Go to Your WordPress Dashboard:<\/strong> Navigate to <strong>Appearance &gt; Themes<\/strong>.<\/li>\n<li><strong>Activate Your Child Theme:<\/strong> You should now see your child theme listed. Click <strong>Activate<\/strong>.<br \/>\n<img decoding=\"async\" src=\"https:\/\/debugspot.com\/blogs\/wp-content\/uploads\/2024\/09\/create-child-theme.png\" alt=\"create child theme\" width=\"\" height=\"\" \/><\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_5_Customize_Your_Child_Theme\"><\/span>Step 5: Customize Your Child Theme<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li><strong>Adding Custom Styles:<\/strong> You can now add custom CSS to your child theme\u2019s style.css file.<\/li>\n<li><strong>Modifying Template Files:<\/strong> Copy any template files from the parent theme into your child theme\u2019s folder to modify them (e.g., header.php, footer.php). Make sure to maintain the same file structure as the parent theme.<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Create_a_Child_Theme\"><\/span>Why Create a Child Theme?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Creating a child theme allows you to modify and customize your WordPress theme without losing changes when the parent theme is updated. It\u2019s a safe and efficient way to ensure your customizations are preserved.<\/p>\n<p>Now your child theme is ready, and you can begin customizing your WordPress site!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create a child theme in WordPress, follow these steps: Step 1: Create a New Child Theme Folder Access Your WordPress Files: Use an FTP client (like FileZilla) or access your hosting control panel (e.g., cPanel) to navigate to the WordPress directory. Go to the Themes Directory: Open wp-content\/themes\/. Create a New Folder: Inside the themes directory, create a new folder for your child theme. Name it appropriately, such as yourtheme-child, where &#8220;yourtheme&#8221; is the parent theme\u2019s name. Step 2: Create a style.css File Create a New style.css File: Inside the child theme folder, create a file named style.css. Add the Required Header Information: Add the following code to the style.css file: \/* Theme Name: Your Theme Child Template: yourtheme Version: 1.0 *\/ Theme Name: Name of your child theme. Template: The folder name of your parent theme (e.g., &#8220;yourtheme&#8221;). Version: Version number of your child theme. Step 3: Create a functions.php File (for Enqueuing Styles) Create a New functions.php File: Inside the child theme folder, create a file named functions.php. Enqueue the Parent Theme\u2019s Stylesheet: Add the following code to your functions.php file: function yourtheme_child_enqueue_styles() { wp_enqueue_style( &#8216;parent-style&#8217;, get_template_directory_uri() . &#8216;\/style.css&#8217; ); } add_action( &#8216;wp_enqueue_scripts&#8217;, &#8216;yourtheme_child_enqueue_styles&#8217; ); This ensures &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"rank_math_lock_modified_date":false,"footnotes":""},"categories":[29],"tags":[35,36],"class_list":["post-1487","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-child-theme","tag-create-child-theme-in-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1487"}],"collection":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/comments?post=1487"}],"version-history":[{"count":10,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1487\/revisions"}],"predecessor-version":[{"id":1518,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1487\/revisions\/1518"}],"wp:attachment":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/media?parent=1487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/categories?post=1487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/tags?post=1487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}