{"id":41714,"date":"2025-10-17T01:12:52","date_gmt":"2025-10-16T22:12:52","guid":{"rendered":"https:\/\/coma.lv\/2025\/10\/17\/what-is-a-child-theme\/"},"modified":"2025-10-17T01:12:52","modified_gmt":"2025-10-16T22:12:52","slug":"what-is-a-child-theme","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/10\/17\/what-is-a-child-theme\/","title":{"rendered":"What Is a Child Theme"},"content":{"rendered":"\n<p style=\"text-align: left;\">A child theme in WordPress is a sub-theme that inherits the functionality, structure and styles of a parent theme. It lets you make changes safely without touching the files of the original theme. When the parent theme is updated, all the edits you made in the child theme keep working, and the update does not erase your changes. That is why working through a child theme is considered a reliable way to customize. You do not change the parent theme&#8217;s files; you create overridden versions of them in the child theme.<\/p>\n<p style=\"text-align: left;\" data-start=\"970\" data-end=\"1529\">To create a child theme, you need to create a separate folder inside the themes directory. The main file without which it will not be recognized is <strong data-start=\"1113\" data-end=\"1126\">style.css<\/strong>. Its header specifies the parent theme through the <code data-start=\"1189\" data-end=\"1199\">Template<\/code> parameter, which must exactly match the name of the parent theme&#8217;s folder. After the child theme is activated, its styles are loaded on top of the parent&#8217;s styles, so you can override any CSS rules. The parent theme continues to work fully, providing the functionality you have not changed in the child theme.<\/p>\n<h2 style=\"text-align: left;\" data-start=\"1536\" data-end=\"1589\">Example of a correct child theme <code data-start=\"1564\" data-end=\"1575\">style.css<\/code> file<\/h2>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n\/*\r\n Theme Name:   My Child Theme\r\n Theme URI:    https:\/\/example.com\/\r\n Description:  Child theme for the Twenty Twenty-Five theme\r\n Author:       Your Name\r\n Author URI:   https:\/\/example.com\/\r\n Template:     twentytwentyfive\r\n Version:      1.0.0\r\n Text Domain:  my-child-theme\r\n*\/\r\n\r\n\/* \u0412\u0430\u0448\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0442\u0438\u043b\u0438 *\/\r\n\r\n<\/pre>\n<p style=\"text-align: left;\"><strong data-start=\"1914\" data-end=\"1924\">Important:<\/strong><br data-start=\"1924\" data-end=\"1927\" \/><code data-start=\"1927\" data-end=\"1938\">Template:<\/code> must be <em data-start=\"1951\" data-end=\"1959\">exactly<\/em> the name of the parent theme&#8217;s folder. For example, if the theme is located in <code data-start=\"2027\" data-end=\"2064\">\/wp-content\/themes\/twentytwentyfive<\/code>, then <code data-start=\"2069\" data-end=\"2097\">Template: twentytwentyfive<\/code>.<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\">Example <code data-start=\"2115\" data-end=\"2130\">functions.php<\/code> for loading the styles correctly<\/h2>\n<p style=\"text-align: left;\" data-start=\"2167\" data-end=\"2327\">Although a child theme can work without its own <code data-start=\"2220\" data-end=\"2235\">functions.php<\/code>, in practice it is almost always needed \u2014 first of all to load the parent theme&#8217;s styles.<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\" style=\"text-align: left;\">\n<div class=\"sticky top-9\">\n<div class=\"absolute end-0 bottom-0 flex h-9 items-center pe-2\">\n<div>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\nadd_action( &amp;#039;wp_enqueue_scripts&amp;#039;, &amp;#039;my_child_theme_styles&amp;#039; );\r\nfunction my_child_theme_styles() {\r\n    \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0435\u043c\u044b\r\n    wp_enqueue_style(\r\n        &amp;#039;parent-style&amp;#039;,\r\n        get_template_directory_uri() . &amp;#039;\/style.css&amp;#039;\r\n    );\r\n\r\n    \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u0442\u0435\u043c\u044b\r\n    wp_enqueue_style(\r\n        &amp;#039;child-style&amp;#039;,\r\n        get_stylesheet_directory_uri() . &amp;#039;\/style.css&amp;#039;,\r\n        array( &amp;#039;parent-style&amp;#039; )\r\n    );\r\n}\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<h2 data-start=\"2856\" data-end=\"2889\">Child Theme File Structure<\/h2>\n<p data-start=\"2891\" data-end=\"2926\">The minimal structure looks like this:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"sticky top-9\">\n<div class=\"absolute end-0 bottom-0 flex h-9 items-center pe-2\">\n<div class=\"bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs\">\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">my-child-theme\/\r\n\u2502\r\n\u251c\u2500\u2500 style.css \u2190 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\r\n\u251c\u2500\u2500 functions.php \u2190 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0438\u043b\u0435\u0439 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434\r\n\u2514\u2500\u2500 screenshot.png \u2190 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e) \u043c\u0438\u043d\u0438\u0430\u0442\u044e\u0440\u0430 \u0442\u0435\u043c\u044b \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">You can add any files to the child theme with the same structure as in the parent. If a file exists in both the parent and the child theme, the child&#8217;s file is used.<\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">\n<p data-start=\"3312\" data-end=\"3343\">Example of a template override:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"sticky top-9\">\n<div class=\"absolute end-0 bottom-0 flex h-9 items-center pe-2\">\n<div class=\"bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs\">\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">my-child-theme\/\r\n\u2514\u2500\u2500 header.php \u2190 \u0437\u0430\u043c\u0435\u043d\u0438\u0442 header.php \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0435\u043c\u044b\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<h2 data-start=\"3431\" data-end=\"3473\"><code data-start=\"3444\" data-end=\"3456\">theme.json<\/code> Support in Child Themes<\/h2>\n<p data-start=\"3475\" data-end=\"3621\">If the parent theme is a block theme (FSE), it uses a <code data-start=\"3552\" data-end=\"3564\">theme.json<\/code> file. In a child theme you can create your own <code data-start=\"3603\" data-end=\"3615\">theme.json<\/code> \u2014 it:<\/p>\n<ul>\n<li data-start=\"3475\" data-end=\"3621\">does not replace but supplements and overrides the parent theme&#8217;s settings<\/li>\n<li data-start=\"3475\" data-end=\"3621\">lets you change colors, typography, block settings, templates and much more<\/li>\n<\/ul>\n<p data-start=\"3787\" data-end=\"3836\">Example of a minimal <code data-start=\"3807\" data-end=\"3819\">theme.json<\/code> in a child theme:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n{\r\n  &amp;quot;version&amp;quot;: 2,\r\n  &amp;quot;settings&amp;quot;: {\r\n    &amp;quot;color&amp;quot;: {\r\n      &amp;quot;palette&amp;quot;: &#x5B;\r\n        {\r\n          &amp;quot;name&amp;quot;: &amp;quot;\u0411\u0440\u0435\u043d\u0434\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442&amp;quot;,\r\n          &amp;quot;slug&amp;quot;: &amp;quot;brand&amp;quot;,\r\n          &amp;quot;color&amp;quot;: &amp;quot;#0066ff&amp;quot;\r\n        }\r\n      ]\r\n    }\r\n  }\r\n}\r\n\r\n<\/pre>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>A child theme in WordPress is a sub-theme that inherits the functionality, structure and styles of a parent theme. It lets you make changes safely without touching the files of the original theme. When the parent theme is updated, all the edits you made in the child theme keep working, and the update does not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37611,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1405],"tags":[],"class_list":["post-41714","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-terms"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41714"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41714\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37611"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}