Title: Child theme template problem when filename.php changed
Last modified: August 20, 2016

---

# Child theme template problem when filename.php changed

 *  Resolved [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/)
 * Hi all,
 * I am creating a basic child theme for Twenty Eleven and wanted the existing sidebar-
   page.php as my home page WITH a full width Easy Rotator plugin positioned under
   the main navigation on this page.
 * I added the side-bar.php file to the child theme, added the plugin into the PHP,
   created a div in the CSS file and it works fine.
 * Obviously the side-bar.php in the child then made every page on the site using
   this template display the slider plugin.
 * So I changed the FILE name to side-bar-child.php but the styling of the page 
   content seems to revert to the sample page template styling, i.e, it introduced
   a large left boarder which pushed the widgets under the content.
 * If i change the file name back to what it was, it works fine.
 * What am I missing here? How has changing the file name messed up the styling 
   of the content?
 * See the home page here: [http://greenhat-test.co.uk/](http://greenhat-test.co.uk/),
   and see also the side bar template on the main navigation. They both use the 
   EXACTLY the same code on the PHP but have different file names?
 * Many thanks for any assistance!
 * Sealyspeak

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Abhishek Ghosh](https://wordpress.org/support/users/abhishek_ghosh/)
 * (@abhishek_ghosh)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068766)
 * You need a `home.php` for your child theme. That basically will be a modified`
   side-bar-child.php`. Add the php hook of Easy Rotator plugin plugin inside `home.
   php` file and your wish will be fulfilled. But you have to define home page style
   in CSS file too. Otherwise it will inherit other CSS div style.
    The sidebar 
   is looking great in Side bar template page.
 *  Thread Starter [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068908)
 * Cheers Abhishek, thanks for your reply.
 * just a couple of questions if I may, and I know I am missing something basic 
   here so I apologise in advance.
 * I have created home.php (as a template.php file in the child theme) and chose
   this page template as my home template page, but where and what should I add 
   to the CSS file?
 * First off, the home.php is a copy paste job from the side-bar.php which is the
   template I wish to build on from Twenty Eleven, so the divs and styles already
   exist in the original twenty eleven theme. I added a slider div and put the properties
   in the styles.css in the child theme.
 * But you are right, the main content area is not pulling in the correct styling?
   I am a little lost.
 * Anyhelp anyone
 *  Thread Starter [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068912)
 * Addition: is the home.php file a template?
 *  [Abhishek Ghosh](https://wordpress.org/support/users/abhishek_ghosh/)
 * (@abhishek_ghosh)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068915)
 * Yes, `home.php` is a template. When it is present in a child theme / theme, the
   settings from WordPress Admin panel will be ignored. It is a php template, should
   be at the root of the child theme / theme’s directory (where we keep `functions.
   php` file). A typical home.php will be like :
 *     ```
       <?php get_header(); ?>
   
       <!-- put HTML, PHP what ever you want -->
   
       <?php get_footer(); ?>
       ```
   
 * Use the CSS in the main CSS file, style.css, typically starting to define with:
 *     ```
       #content-home {
       color:#whatever;
       font-size:xypx;
       font-family:georgia, times, serif;
       margin:0 auto;
       }
       ```
   
 * You can add the block of CSS defining home’s design at the end of the `style.
   css` file.
    You can add more flexibility of home by using `register_sidebar(array`
   in `functions.php` file (and styling with CSS). Depending upon your settings,
   they will appear on your WordPress Widget list inside your WordPress installation.
   Drag and drop things you want.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068916)
 * the correction for the sidebar in a ‘sidebar template’ are done in functions.
   php, using the template file name;
 * for a new sidebar template, you need to add some code to functions.php of hte
   child theme.
 * see my article:
    [http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction](http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction)
 *  Thread Starter [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068927)
 * Many many thanks for getting back to me!
 * Can I just ask, why does the template not just use the CSS from the original 
   theme if none of the DIV names have been changed?
 * I ended up copying EVERYTHING from the original CSS into the styles.css in the
   child theme and it still did not work?
 * Not sure why this is happening still? It seems like the CSS link to the correct
   styling gets lost when I change the file name from side-bar.php to home.php (
   I remove all the template code so it starts: <?php get_header…) in the child 
   theme. When I change the file name back to side-bar.php the CSS styling is fine?
 * Wow, don’t remember having this problem with CSS styling on a child theme.I really
   want to understand this! Sorry guys.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068930)
 * > Can I just ask, why does the template not just use the CSS from the original
   > theme if none of the DIV names have been changed?
 * this is just the way it is;
 * Twenty Eleven controls the sidebar layour via the ‘body_class()’ css class `.
   singular` which is set and controlled near the end of functions.php;
 * this is the line which add this `.singular` class:
 *     ```
       if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
       		$classes[] = 'singular';
       ```
   
 * as you can see, the class is added for ‘singular’ posts, pages, attachments; 
   but **not **if it is the ‘posts page’, ‘showcase’ template, or ‘sidebar template’;
 * however, as any static page (regardless of the page template) would in the first
   place be seen as belonging to the ‘singular’ type, it would get the `.singular`
   class (which in turn changes the formatting -> check for instance style.css for
   all the styles that start with `.singular` …).
 * unfortunatley, when creating a new page template with a sidebar, one needs to
   take this into account and adjust the ‘body_class()’ output – for instance with
   the kind of coding as I have suggested.
 * > I ended up copying EVERYTHING from the original CSS into the styles.css in 
   > the child theme and it still did not work?
 * it seems that you haven’t read and applied the suggestion from my last reply.
 * to save you clicking the link, here the code which needs to be added into [functions.php of the child theme ](http://codex.wordpress.org/Child_Themes#Using_functions.php)(
   substitute your own page template file name _**side-bar.php **_):
 *     ```
       add_filter('body_class', 'adjust_body_class_for_page_template', 20, 2);
       function adjust_body_class_for_page_template($wp_classes, $extra_classes) {  
   
       if( is_page_template('side-bar.php') ) :
       // Filter the body classes      
   
             foreach($wp_classes as $key => $value) {
             if ($value == 'singular') unset($wp_classes[$key]);
             } 
   
       endif;
       // Add the extra classes back untouched
       return array_merge($wp_classes, (array) $extra_classes );
       }
       ```
   
 *  [Abhishek Ghosh](https://wordpress.org/support/users/abhishek_ghosh/)
 * (@abhishek_ghosh)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068937)
 * Excellent elaborated reply, alchymyth.
 *  Thread Starter [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068943)
 * Agreed, I could not fail with that amount of detail and source code!
 * To you both, a massive thumbs up. Thanks for your time!
 *  Thread Starter [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * (@sealyspeak)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068944)
 * Forgot to resolve topic…

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Child theme template problem when filename.php changed’ is closed to 
new replies.

## Tags

 * [template](https://wordpress.org/support/topic-tag/template/)
 * [twenty eleven child](https://wordpress.org/support/topic-tag/twenty-eleven-child/)

 * 10 replies
 * 3 participants
 * Last reply from: [sealyspeak](https://wordpress.org/support/users/sealyspeak/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/child-theme-template-problem-when-filenamephp-changed/#post-3068944)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
