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

Child Theme Help, The theme has been installed but Template is missing...

Hello, I have wordpress installed on my server, so the one minute click install, an not on my pc, "famous 5 minutes install" I downloaded cyberduck as FTP.. something might have gone wrong because on my dashboard on wordpress it states that the child theme was downloaded but the css is missing. However I'm pretty sure I didn't miss any passages. My code is this:

This is for functions php: <? php add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() { wp_enqueue_style( 'parent-style', get_stylesheet_directory_uri().'/style.css' ); } ?>

and for the style.css is this:

/* Theme Name: Vantage Child Theme URI: http://example.com Description: Child Theme for vantage Theme Author: Gabriele Author URI: http://example.com Template: vantage Version: 1.4.2 */

Is it possible that the error might have happened because I didn't download WP on my pc, but only on my server? Actually I've tried several times to create a child theme directly on my file manager on the server, without using an ftp, and I was having the very same problem I have right now, but the customer service told me it was because I needed to use an FTP, since the files were to big, to be handled directly on the file manager (whaaat?? i mean come on!) anyway, I did use a damn FTP this time, and it keeps giving me the same error, telling me the template is missing the stylesheet! Now what? Like I said, could that be due to the fact I don't have wordpress installed locally? ( even though I doubt it) PLEASE DO NOT RESPOND TO THIS QUESTION IF YOU DON'T KNOW WHAT YOU ARE TALKING ABOUT. MAKE SURE YOU ARE POSITVE AND KNOWLEDGEABLE ABOUT THIS SPECIFIC TOPIC. SO IF U ARE A STUDENT THAT THINKS TO KNOW THE ANSWER, JUST REFRAIN FROM WRITING. PLEASE. ONLY PEOPLE WITH EXPERIENCE AND THAT ARE POSITIVE ABOUT WHAT THEY ARE TALKING. Sorry I don't want to sound rude, but I really need to solve this problem, and I need people that really could give me the right answers to that. I appreciate your understanding! We are on the same boat. P.S. I don't know why the code I had written on the preview that was looking normal, now it's been placed on a line.. :/

Thanks a lot!

Gabe

3 Answers

Dustin Leer
Dustin Leer
21,063 Points

Hello Gabe,

It looks like you aren't referencing the correct stylesheets. You are not referencing the parent theme style sheets in your function with "get_stylesheet_directory_uri()" to correctly reference the parent stylesheet you need to write "get_template_directory_uri()" then you need to follow it with a second wp_enqueue where you then reference the child theme's style sheet with "get_stylesheet_directory_uri()". A great way to check this is to look at a theme called Underscores it is made by Automattic the makers of WordPress it is a very basic start theme that encourages you to make the next great WordPress theme it's on GitHub. I really hope this helps you get your theme underway Gabe! Best of luck and happy coding!

Your Code

<? php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); 
function enqueue_parent_styles() { 
      wp_enqueue_style( 'parent-style', get_stylesheet_directory_uri().'/style.css' );
}
?>

The correct you need

<?php
/**
 * Enqueue scripts and styles.
 */
function namescript_scripts() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
              get_stylesheet_directory_uri() . '/style.css',
              array('parent-style')
    );
}
add_action( 'wp_enqueue_scripts', 'namescript_scripts_scripts' );

?>

Cheers,

-Dustin

Hello Dustin,

Thank you so much for your help and reply! Now it looks like the child theme has been created because there's the thumbnail on the dashboard, but when I try to activate it and open it up, I get the following errors: Warning: include(/home3/gabe2001/public_html/wordpress/wp-content/themes/twentyfourteen-child/functions.php): failed to open stream: No such device in /home3/gabe2001/public_html/wordpress/wp-settings.php on line 329

Warning: include(): Failed opening '/home3/gabe2001/public_html/wordpress/wp-content/themes/twentyfourteen-child/functions.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home3/gabe2001/public_html/wordpress/wp-settings.php on line 329

Warning: include(/home3/gabe2001/public_html/wordpress/wp-content/themes/twentyfourteen-child/index.php): failed to open stream: No such device in /home3/gabe2001/public_html/wordpress/wp-includes/template-loader.php on line 74

Warning: include(): Failed opening '/home3/gabe2001/public_html/wordpress/wp-content/themes/twentyfourteen-child/index.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home3/gabe2001/public_html/wordpress/wp-includes/template-loader.php on line 74

Do you understand by reading those, where the bug could be? I followed all the steps, I'm kinda stuck. Hostgator tech support told me there might be a problem with the PHP version and I should go on the PHP control panel plugin admin and change version.. But I'm afraid I could mak things worse.. Could that be the problem anyway?

Thanks a lot!

UPDATE: Well now it seems I managed to make it work. I carefully read the errors above, and went to those directories, directly from cp-file manager, and I found the lines mentioned in the errors. I copied'em up on notepad, and edited by deleting them from the code in those directories. After that, I re-pasted them right where they used to be, saved changes, and refreshed the page. And it worked..! However, I didn't put the index.php into the child-theme folder. Might have actually been the fact I didn't create a folder named index.php, the reason for now being seeminlgy alright?

Thanks Dustin,

  • Gabe
Dustin Leer
Dustin Leer
21,063 Points

Hey Gabe,

The only files you should need initially for you child theme are a blank functions.php to pull in your enqueue scripts and stylesheets, a style.css doc to insert your styles and then a thumbnail image. Unless you are going to make changes to the other files in your parent theme you really don't need them in you child theme directory.

Hope this help you.

Cheers,

-Dustin

Hello Dustin, Thank you for taking the time to help. I'd like to learn very well how to modify and customize a child theme, by using code. It'll take time to master it, but I'm willing to put effort into it. And thanks to supporting people like you, it's great, because one never feels alone. Thanks again! Cheers,

 Gabe