{"id":149194,"date":"2015-04-30T23:12:54","date_gmt":"2015-04-30T21:12:54","guid":{"rendered":"https:\/\/elmastudio.de\/?p=149194"},"modified":"2026-09-15T14:48:39","modified_gmt":"2026-09-15T12:48:39","slug":"how-to-create-a-wordpress-child-theme-the-right-way","status":"publish","type":"post","link":"https:\/\/elmastudio.de\/en\/how-to-create-a-wordpress-child-theme-the-right-way\/","title":{"rendered":"How To Create A WordPress Child Theme &#8211; The Right Way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Since recently it was considered best practice in WordPress to include the parent stylesheet <em>(style.css)<\/em> with the <em>@import<\/em> rule  in your child theme&#8217;s style.css. However this technique got updated and now it&#8217;s best-practice to create a functions.php file for your child theme and use <em>wp_enqueue_style()<\/em> to include you parent theme stylesheet this way. I will show you shortly how this is done.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create your functions.php<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So now next to your stylesheet <em>style.css<\/em> file and the <em>screenshot.png<\/em> file with your child themes preview image, you will also need to create a <em>functions.php<\/em> file for your child theme folder. You can use a text editor like Notepad++, Coda2 or Sublime Text to create your new <em>functions.php<\/em> file. The content of the file should include the following code snippet:<\/p>\n\n\n<figure class=\"code-block quire-fill-fade\" data-lines=\"14\"><div class=\"code-block-controls quire-surface\"><span class=\"quire-tooltip code-block-fold-tip\" data-side=\"top\"><button type=\"button\" class=\"quire-icon-button code-block-fold\" aria-label=\"Show all 14 lines\" data-label-open=\"Show fewer lines\" hidden><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon\"><path d=\"m7 15 5 5 5-5\"\/><path d=\"m7 9 5-5 5 5\"\/><\/svg><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon is-open\"><path d=\"m7 20 5-5 5 5\"\/><path d=\"m7 4 5 5 5-5\"\/><\/svg><\/button><span class=\"quire-tooltip-bubble\" role=\"tooltip\">Show all 14 lines<\/span><\/span><span class=\"quire-tooltip code-block-copy-tip\" data-side=\"top\"><button type=\"button\" class=\"quire-icon-button code-block-copy\" aria-label=\"Copy code\" hidden><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"\/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"\/><\/svg><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon is-done\"><path d=\"M20 6 9 17l-5-5\"\/><\/svg><\/button><span class=\"quire-tooltip-bubble\" role=\"tooltip\">Copy code<\/span><\/span><\/div>\n<pre class=\"wp-block-code\"><code><span class=\"code-line\">&lt;?php<\/span><span class=\"code-line\">\/**<\/span><span class=\"code-line\"> * Theme Name child theme functions and definitions<\/span><span class=\"code-line\"> *\/<\/span><span class=\"code-line\"><\/span><span class=\"code-line\">\/*\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014*\/<\/span><span class=\"code-line\">\/* Include the parent theme style.css<\/span><span class=\"code-line\">\/*\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014*\/<\/span><span class=\"code-line\"><\/span><span class=\"code-line\">add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );<\/span><span class=\"code-line\">function theme_enqueue_styles() {<\/span><span class=\"code-line\">    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '\/style.css' );<\/span><span class=\"code-line\"><\/span><span class=\"code-line\">}<\/span><\/code><\/pre>\n<div class=\"code-block-more-row\"><button type=\"button\" class=\"code-block-fold code-block-more quire-button small\" aria-label=\"Show all 14 lines\" data-label-open=\"Show fewer lines\" hidden>Show all 14 lines<\/button><\/div><\/figure>\n\n\n<p class=\"wp-block-paragraph\">Now you included your parent theme&#8217;s stylesheet via the <em>functions.php<\/em> and you will only need your child theme&#8217;s  <em>style.css<\/em> file to add your own CSS to your theme. Your child theme&#8217;s <em>style.css<\/em> file should start like this:<\/p>\n\n\n<figure class=\"code-block quire-fill-fade\" data-lines=\"15\"><div class=\"code-block-controls quire-surface\"><span class=\"quire-tooltip code-block-fold-tip\" data-side=\"top\"><button type=\"button\" class=\"quire-icon-button code-block-fold\" aria-label=\"Show all 15 lines\" data-label-open=\"Show fewer lines\" hidden><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon\"><path d=\"m7 15 5 5 5-5\"\/><path d=\"m7 9 5-5 5 5\"\/><\/svg><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon is-open\"><path d=\"m7 20 5-5 5 5\"\/><path d=\"m7 4 5 5 5-5\"\/><\/svg><\/button><span class=\"quire-tooltip-bubble\" role=\"tooltip\">Show all 15 lines<\/span><\/span><span class=\"quire-tooltip code-block-copy-tip\" data-side=\"top\"><button type=\"button\" class=\"quire-icon-button code-block-copy\" aria-label=\"Copy code\" hidden><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"\/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"\/><\/svg><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon is-done\"><path d=\"M20 6 9 17l-5-5\"\/><\/svg><\/button><span class=\"quire-tooltip-bubble\" role=\"tooltip\">Copy code<\/span><\/span><\/div>\n<pre class=\"wp-block-code\"><code><span class=\"code-line\">\/*<\/span><span class=\"code-line\"> Theme Name: Theme Name Child<\/span><span class=\"code-line\"> Theme URI:<\/span><span class=\"code-line\"> Description: Theme Name Child Theme<\/span><span class=\"code-line\"> Author: Your Name<\/span><span class=\"code-line\"> Author URI: http:\/\/www.yourdomain.com\/<\/span><span class=\"code-line\"> Template: yourparentthemetextdomain<\/span><span class=\"code-line\"> Version: 1.0<\/span><span class=\"code-line\"> License: GNU General Public License v2 or later<\/span><span class=\"code-line\"> License URI: http:\/\/www.gnu.org\/licenses\/gpl-2.0.html<\/span><span class=\"code-line\"> Tags: Theme Name Child Theme<\/span><span class=\"code-line\">*\/<\/span><span class=\"code-line\"><\/span><span class=\"code-line\">\/*<\/span><span class=\"code-line\">You can start adding your own styles here. Use !important to overwrite styles if needed. *\/<\/span><\/code><\/pre>\n<div class=\"code-block-more-row\"><button type=\"button\" class=\"code-block-fold code-block-more quire-button small\" aria-label=\"Show all 15 lines\" data-label-open=\"Show fewer lines\" hidden>Show all 15 lines<\/button><\/div><\/figure>\n\n\n<h2 class=\"wp-block-heading\">Note on Elmastudio Child themes:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At Elmastudio we also updated all your theme&#8217;s starter child theme folders to using the new method. In case you are already using a child theme you can update your child theme very easily as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You only need to add the code showed above in the <em>functions.php<\/em> file of your child theme or create a new <em>functions.php<\/em> file for your child theme with the above explained code. You can also just download the example functions.php file we created to get you started.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You also need to delete the following code snippet in your existing style.css:<\/p>\n\n\n<figure class=\"code-block quire-fill-fade\" data-lines=\"2\"><div class=\"code-block-controls quire-surface\"><span class=\"quire-tooltip code-block-copy-tip\" data-side=\"top\"><button type=\"button\" class=\"quire-icon-button code-block-copy\" aria-label=\"Copy code\" hidden><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"\/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"\/><\/svg><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"code-block-icon is-done\"><path d=\"M20 6 9 17l-5-5\"\/><\/svg><\/button><span class=\"quire-tooltip-bubble\" role=\"tooltip\">Copy code<\/span><\/span><\/div>\n<pre class=\"wp-block-code\"><code><span class=\"code-line\">\/* This will import the stylesheet from the Theme Name parent theme *\/<\/span><span class=\"code-line\">@import url('..\/yourthemename\/style.css');<\/span><\/code><\/pre>\n<\/figure>\n\n\n<h3 class=\"wp-block-heading\">Your Feedback and Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Do you have further tips or questions regarding child themes? Please just write a comment to the post below, we are looking forward to hear from you!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Further helpful links regarding WordPress child themes:<br \/>\n&#8211; <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\">Child Theme information<\/a> on the WordPress.org website<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Since recently it was considered best practice in WordPress to include the parent stylesheet (style.css) with the @import rule in your child theme&#8217;s style.css. However this technique got updated and now it&#8217;s best-practice to create a functions.php file for your child theme and use wp_enqueue_style() to include you parent theme stylesheet this way. I will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":149302,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","jetpack_seo_llms_txt_always_include":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[910],"tags":[1412,1401,1415,1307,1466,1418],"class_list":["post-149194","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-en","tag-child-theme-en","tag-featured-en","tag-parent-theme-en-2","tag-tips","tag-visitenkarten-en","tag-wordpress-beginners"],"jetpack_shortlink":"https:\/\/wp.me\/phlOHV-COm","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/elmastudio.de\/wp-content\/uploads\/2015\/04\/wordpress-child-themes-thumb1.jpg","_links":{"self":[{"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/posts\/149194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/comments?post=149194"}],"version-history":[{"count":3,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/posts\/149194\/revisions"}],"predecessor-version":[{"id":314618,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/posts\/149194\/revisions\/314618"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/media\/149302"}],"wp:attachment":[{"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/media?parent=149194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/categories?post=149194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elmastudio.de\/en\/wp-json\/wp\/v2\/tags?post=149194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}