Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Make a Website with WordPress Customizing WordPress Themes How to Make Child Themes

I am using a theme from WP. When I create child folder, and insert style.css file, no content shows.

I am using a Vantage theme from WP. When I installed this theme, the VANTAGE folder was created in wp-content/themes/ directory. I wanted to make a child theme. Therefore I created a VANTAGE_CHILD folder in /themes directory. Inside this folder I entered style.css and screenshot. jpg files. (In style.css folder I added Template Name: Vantage and import command for ../vantage/style.css file). Problem is - no contet is visible when I activate child theme (I previously added plenty of content using the original theme. Now I am getting only a blank page).

Do I either have to add the mentioned files style.css, screenshot.jpg (and maybe functions.php), or do I have to copy ALL the files from the original theme?

If 1) what am I doing wring? Thx!

6 Answers

Always avoid duplicating files when you can, ensure that you import things that need to be included. This is best done in the functions.php file in your child theme. Consider a snippet from codex.wordpress.org:

"The final step is to enqueue the parent and child theme stylesheets. Note that the previous method was to import the parent theme stylesheet using @import: this is no longer best practice. The correct method of enqueuing the parent theme stylesheet is to use wp_enqueue_script() in your child theme's functions.php. You will therefore need to create a functions.php in your child theme directory. The first line of your child theme's functions.php will be an opening PHP tag (<?php), after which you can enqueue your parent and child theme stylesheets. The following example function will only work if your Parent Theme uses only one main style.css to hold all of the css. If your theme has more than one .css file (eg. ie.css, style.css, main.css) then you will have to make sure to maintain all of the Parent Theme dependencies. Setting 'parent-style' as a dependency will ensure that the child theme stylesheet loads after it. "

The codex is a great resource when learning how to build and update wordpress elements. http://codex.wordpress.org/Child_Themes

Good Luck

I do not get it... I mean if you buy a theme, then you get corresponding files. But then it is recommended to create a child theme for a number of reasons. I have succeeded in creating a child theme ie. I created a child folder with style.css file. In the file I used Template command in the comment, and referrenced to the original theme.

Now, I think I HAVE to use @import function, to import style.css from the original theme. I mean, I could make a functions.php file and enqueue the style script. However, where would I include it? At this phase I do not have index.php, header.php, footer.php or other files. So the question is - if I use the functions.php and enqueue scripts function in the child theme, what do I need to do in order to show the frontend that comes from the original theme?

Adam,

It's really hard to say without seeing the actual code... After reviewing your question, my best advice would be to ensure that the commented header in your style.css matches the required format. Pay special attention to the "Template" section as this line indicates the appropriate parent theme. It needs to exactly match the directory name of your parent theme folder. Capitalization matters.

/*
 Theme Name:   Twenty Fifteen Child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentyfifteen    <-- THIS LINE MUST INDICATE THE CORRECT PARENT DIRECTORY***
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fifteen-child
*/

The best resource for information on child theme development is the wordpress codex. You could also carefully review Zac Gordon's instructions.

If this does not help, wordpress will usually throw errors when a parent theme cannot be found, are you getting any errors when you activate the child theme?

Hope this helps!

Thanks for the feedback.

The problem is not in getting the original look from the original theme. I solved that. However I solved it using import function. Here is style.css script inside the child folder:

        Theme Name: Vantage
        Template: Vantage

        @import url("../vantage/style.css");

I asked another question when you mentioned I shoud use functions.php and enqueue scripts. And I'd like to mention that I know how to make the functions.php script and write the code. I also know I have to incude it with wp_head() and wp_footer(). However I do not know where to incude it? I do not have index.php, header.php, footer.php scripts (I am getting the frontend from the original theme only with style.css script. Apart from style.css script there is nothing else in my child folder.) Hope I was clearer now.

I'm not entirely sure what you are asking...

You put your functions.php for the child theme, as well as all other files you want to override your parent theme files, in the child theme folder.

Also, it's okay to use @import, it just isn't best practice.

Does that answer your question?

at the initial phase I do not want to override anything. at this phase in the child folder I only have style.css file. This file uses import function to import the css from the original theme. This approach, although not best practice, functions.

BUT, I would like to implement the best practice approach ie to use functions.php file. So let's assume I create functions.php file (at this moment my child folder would contain 2 files: style.css and functions.php files). Let's also assume I insert the right code into functions.php file, and that I deleted import statement from the style.css file. NOW, I am assuming that one thing is missing ie I won't get the frontend from the original theme. And the thing that is missing is including the functions.php file somewhere. Now, normally I saw in the videos, you would include the functions.php in index.php file by using commands such as wp_head() or wp_footer(). The problem is: my child folder ONLY contains style.css and functions.php files. So - how to follow the best practice (using functions.php file) for enqueueing scripts? Where should I include the functions.php file? Style.css? I doubt I should use it there...