I have a theme that I’ve developed and want to make child themes. My wp-content/themes
directory looks something like this:
parenttheme
|- style.css
|- functions.php
|- index.php
|- page-example.php
childtheme
|- style.css
|- functions.php
|- index.php
The problem is that page-example.php
doesn’t load in a site using childtheme
, only childtheme/index.php
is used.
I can do something like this in childtheme/index.php
:
echo body_class(); // class="page page-id-24 page-template page-template-page-example page-template-page-example-php logged-in admin-bar no-customize-support"
The correct looking classes are there (page-template-page-example
), but it’s not using the parenttheme template file.
My hacky solution so far is to add a childtheme/page-example.php
file that just contains a require('parenttheme/page-example.php')
, but it seems like I shouldn’t have to do that.
I found this post, which seems to be my exact problem, but there was no answer… Can I create new page.php on child theme in wordpress?
I’ve read through the WordPress child theme codex and exhausted all other resources I can think of on the topic. Is there anyone who has dealt with this problem before?
I’m using WordPress 4.4 and multisites, if that matters.
The full template in question:
<?php
/*
Template Name: Membership
*/
get_header();
?>
<div class="site-bd">
<div class="wrapper">
<div class="hero">
<?php
if (have_posts()) :
while (have_posts()) :
the_post();
?>
<div class="shelf shelf_3">
<?php the_post_thumbnail(); ?>
</div>
<?php
endwhile;
endif;
?>
</div>
<div class="grid">
<?php
if( have_rows('top_columns') ) :
while ( have_rows('top_columns') ) : the_row();
?>
<div class="grid_item grid_item-oneThird">
<div class="shelf">
<div class="shelf">
<?php the_sub_field('column_1'); ?>
</div>
<ul class="vList">
<li>
<a href="#" class="btn" target="_blank">Join or Renew Online</a>
</li>
<li>
<a href="#" class="btn" target="_blank">Download Membership Form</a>
</li>
</ul>
</div>
</div><div class="grid_item grid_item-oneThird">
<div class="box">
<div class="shelf">
<?php the_sub_field('column_2'); ?>
</div>
</div>
</div><div class="grid_item grid_item-oneThird">
<div class="box">
<div class="shelf">
<?php the_sub_field('column_3'); ?>
</div>
</div>
</div>
<?php
endwhile;
endif;
?>
</div>
</div>
</div>
<?php get_footer(); ?>
I’ve got a dozen or so other templates that also don’t work though.
This is the message I was talking about in the comments. This is shown on the themes page of a child theme:
If not you may not have your child theme setup correctly. Make sure your child theme
style.css
file has something like this at the top:with the important part for child themes being the ‘Template’ entry.
Other things you can try:
In
wp-includestemplate.php
check out the functionsload_template()
andlocate_template()
. Useprint_r()
to output what these functions are doing on page load to try and help you diagnose what files are being loaded and where it’s going wrong.Output the function
get_page_template()
in yourfunctions.php
to see what WordPress thinks it’s outputting. This may also help you diangose.Good luck or hope someone else comes along to shed more light.