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

problems creating child theme

According to the codex best way to create to create child theme is use the at functions.php enqueue styles so l got his code in my functions.php of my moesiachild theme

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' ); function enqueue_parent_theme_style() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); } ?>

in my style.css of the child child theme l also got the follow code

/* Theme Name: Moesia Child Theme URI: http://athemes.com/theme/moesia Description: Moesia Child Theme Author: Kelvin Atawura Author URI: http://localhost:8888/wordpress/ Template: Moesia Version: 1.14 Tags: light, two-columns, three-columns, right-sidebar, fluid-layout, responsive-layout, custom-colors, custom-background, custom-header, custom-menu, featured-images, sticky-post, theme-options, threaded-comments, translation-ready Text Domain: moesia-child */

/* =Theme customization starts here -------------------------------------------------------------- */

l seem to have followed all the need directives but this doesn't seem to do the job. l keep getting styles.css missing from moesiachild on my dashbpard theme page. Any ideas of how l can fix this please?

3 Answers

Hello Kelvin Atawura!

The contents of your child theme style.css file should look like this:

/*
 Theme Name:   moesiachild
 Theme URI:    http://www.example.com/
 Description:  moesia child theme
 Author:       Kelvin Atawura
 Author URI:   http://example.com/
 Template:     moesia
 Version:      1.0.0
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
*/


/* =Theme customization starts here
-------------------------------------------------------------- */

The contents of your child theme functions.php file should look like this:

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

?>

From what you wrote, I think that there's a typo in your functions.php file(Maybe you wrote styles.css instead of style.css?)

apparently its not the best way to get style sheets for cild themes according to the codex

If you're looking for performance, then yes. @import is not the best way to do it.

Getting back to your question, could you please paste again your functions.php file again? I think you have a typo in it.

l made a mistake with the stylesheet header comments thats why it wasn't working but managed to fix it now. With the functions.php code here it is. thanks for helping tho mate really appreciated.

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>

No problem.

Have a great weekend and good luck with your learning!

Please make sure to mark your topic as solved if your issue has been fixed.

Got a few more questions however have marked it. You any familiar with this mosia theme then?