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 Build a Website with WordPress Customizing WordPress Themes How to Make Child Themes

Saikat Chowdhury
Saikat Chowdhury
3,128 Points

Is index.php file is required in child theme?

Hello

I am getting below error ,

Broken Themes

The following themes are installed but incomplete.

Name Description

Allegiant Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet.

Do I need to put index.php file into child theme from parent theme.

Regards , Saikat

1 Answer

Simon Duchaine
Simon Duchaine
14,441 Points

Hi Saikat,

Actually, there's only two files required in child theme: the style.css and the functions.php.

I simply think that your style.css is missing the header. Here's an example of the mandatory header of a child theme.

/*
 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
 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
*/

Also, you need to enqueue the parent style sheet by including this in your child theme function.php:

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
?>

I second the last answer. However, I found that index.php truly was required for the admin panel to stop complaining that the theme was broken. So, I kept an empty index.php file in there and life was good.