{"id":597,"date":"2024-06-25T16:30:55","date_gmt":"2024-06-25T16:30:55","guid":{"rendered":"https:\/\/chennaihosting.co.in\/kb\/?p=597"},"modified":"2024-06-25T16:30:57","modified_gmt":"2024-06-25T16:30:57","slug":"create-wordpress-child-theme","status":"publish","type":"post","link":"https:\/\/chennaihosting.co.in\/kb\/create-wordpress-child-theme\/","title":{"rendered":"How to create WordPress child theme"},"content":{"rendered":"\n<p>Creating a <a href=\"https:\/\/wordpress.org\/\" data-type=\"link\" data-id=\"https:\/\/wordpress.org\/\" target=\"_blank\" rel=\"noopener\">WordPress <\/a>child theme allows you to customize your site\u2019s appearance and functionality without altering the original (parent) theme files.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#key-features-of-a-word-press-child-theme\">Key Features of a WordPress Child Theme<\/a><\/li><li><a href=\"#why-use-a-wordpress-child-theme\">Why Use a WordPress Child Theme?<\/a><\/li><li><a href=\"#step-1-create-the-child-theme-folder\">Step 1: Create the Child Theme Folder<\/a><\/li><li><a href=\"#step-2-create-the-style-css-file\">Step 2: Create the style.css File<\/a><\/li><li><a href=\"#step-3-create-the-functions-php-file\">Step 3: Create the functions.php File<\/a><\/li><li><a href=\"#step-4-activate-the-child-theme\">Step 4: Activate the Child Theme<\/a><\/li><li><a href=\"#step-5-customize-the-child-theme\">Step 5: Customize the Child Theme<\/a><\/li><li><a href=\"#example-overriding-a-template-file\">Example: Overriding a Template File<\/a><\/li><li><a href=\"#tips-for-creating-a-child-theme\">Tips for Creating a Child Theme<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"key-features-of-a-word-press-child-theme\">Key Features of a WordPress Child Theme<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Inheritance from Parent Theme:<\/strong>\n<ul class=\"wp-block-list\">\n<li>A child theme automatically inherits all the templates, functions, and styles of the parent theme. This allows you to make modifications or add new functionalities without having to build a theme from scratch.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Customizability:<\/strong>\n<ul class=\"wp-block-list\">\n<li>You can customize your website by overriding specific files of the parent theme in the child theme. For example, you can create a custom <code>header.php<\/code> file in the child theme, and WordPress will use this file instead of the one in the parent theme.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Safety with Updates:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Since your changes are made in the child theme, you can update the parent theme without losing your customizations. This ensures that you can benefit from new features, improvements, and security patches released in parent theme updates.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-use-a-wordpress-child-theme\">Why Use a WordPress Child Theme?<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Safe Customization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It allows for safe and easy customization of your site. Any custom styles or functions can be added to the child theme without affecting the parent theme.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Preservation of Changes:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Updates to the parent theme won\u2019t affect your customizations, as they are stored separately in the child theme.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Ease of Maintenance:<\/strong>\n<ul class=\"wp-block-list\">\n<li>By keeping customizations in a child theme, you can manage and troubleshoot changes more efficiently. It keeps your modifications organized and separate from the core theme files.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This ensures that your changes are preserved even when the parent theme is updated. Here\u2019s a step-by-step guide to creating a WordPress child theme:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-create-the-child-theme-folder\">Step 1: Create the Child Theme Folder<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Access Your WordPress Directory:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Use an FTP client (like FileZilla) or your <a href=\"https:\/\/chennaihosting.co.in\/\" data-type=\"link\" data-id=\"https:\/\/chennaihosting.co.in\/\">hosting provider\u2019s<\/a> file manager to navigate to your WordPress installation directory.<\/li>\n\n\n\n<li>Go to <code>wp-content\/themes\/<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Create a New Folder:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Inside the <code>themes<\/code> directory, create a new folder for your wordpress child theme. Name it something like <code>your-theme-child<\/code> (replace <code>your-theme<\/code> with the name of your parent theme).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-create-the-style-css-file\">Step 2: Create the <code>style.css<\/code> File<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create the <code>style.css<\/code> File:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Inside your child theme folder, create a file named <code>style.css<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Add the Required Header Comment:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Open the <code>style.css<\/code> file and add the following code, customizing it with your theme\u2019s details<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\nTheme Name:   Your Theme Child\nTheme URI:    http:\/\/example.com\/your-theme-child\nDescription:  A child theme of the Your Theme.\nAuthor:       Your Name\nAuthor URI:   http:\/\/example.com\nTemplate:     your-theme\nVersion:      1.0.0\n*\/<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The <code>Template<\/code> line should match the folder name of your parent theme exactly.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-create-the-functions-php-file\">Step 3: Create the <code>functions.php<\/code> File<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create the <code>functions.php<\/code> File:<\/strong>\n<ul class=\"wp-block-list\">\n<li>In the child theme folder, create a file named <code>functions.php<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Enqueue the Parent and Child Theme Styles:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Open the <code>functions.php<\/code> file and add the following <\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nfunction your_theme_child_enqueue_styles() {\n    $parent_style = 'parent-style'; \/\/ This is 'your-theme-style' for your parent theme.\n\n    wp_enqueue_style($parent_style, get_template_directory_uri() . '\/style.css');\n    wp_enqueue_style('child-style',\n        get_stylesheet_directory_uri() . '\/style.css',\n        array($parent_style),\n        wp_get_theme()->get('Version')\n    );\n}\nadd_action('wp_enqueue_scripts', 'your_theme_child_enqueue_styles');<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-activate-the-child-theme\">Step 4: Activate the Child Theme<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Log in to Your WordPress Admin:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to your WordPress dashboard.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Navigate to Appearance &gt; Themes:<\/strong>\n<ul class=\"wp-block-list\">\n<li>You should see your new child theme listed there.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Activate the Child Theme:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Click the \u201cActivate\u201d button for your child theme.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-customize-the-child-theme\">Step 5: Customize the Child Theme<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add Additional Customization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>You can now add custom CSS to the <code>style.css<\/code> file of your child theme.<\/li>\n\n\n\n<li>To override parent theme templates, copy the template file from the parent theme into your child theme folder and then edit it.<\/li>\n\n\n\n<li>You can also add additional PHP functions to the <code>functions.php<\/code> file.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-overriding-a-template-file\">Example: Overriding a Template File<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Copy a Template File:<\/strong>\n<ul class=\"wp-block-list\">\n<li>For example, if you want to customize the <code>header.php<\/code> file:\n<ul class=\"wp-block-list\">\n<li>Copy <code>header.php<\/code> from the parent theme folder.<\/li>\n\n\n\n<li>Paste it into your child theme folder.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Edit the Copied Template File:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Open the copied <code>header.php<\/code> file in your child theme folder and make your desired changes.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"tips-for-creating-a-child-theme\">Tips for Creating a Child Theme<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Keep Customizations Organized:<\/strong> Keep track of all the customizations you make for easier management and debugging.<\/li>\n\n\n\n<li><strong>Test After Updates:<\/strong> After updating the parent theme, check to ensure your customizations still work as expected.<\/li>\n\n\n\n<li><strong>Backup Regularly:<\/strong> Regularly back up your site, including the theme files, to avoid losing your customizations.<\/li>\n<\/ul>\n\n\n\n<p>By following these steps, you can create a WordPress child theme that allows you to safely customize your site&#8217;s design and functionality while preserving the ability to update the parent theme without losing your changes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a WordPress child theme allows you to customize your [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":612,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[],"class_list":["post-597","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/comments?post=597"}],"version-history":[{"count":8,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/597\/revisions"}],"predecessor-version":[{"id":611,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/597\/revisions\/611"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media\/612"}],"wp:attachment":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media?parent=597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/categories?post=597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/tags?post=597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}