Child theme fix: use get_template_part instead include get_template_directory…
-
Another issue with 1.8.2.1 and child themes which we found when adding a custom category filter to
WP_Query()
in latest news section.When putting a file
sections/latest_news.php
in child theme folder, it should be used automatically but it is not. The reason is infront-page.php
of parent theme:if( isset($zerif_latestnews_show) && $zerif_latestnews_show != 1 ): include get_template_directory() . "/sections/latest_news.php"; endif;
The problem is the use of
get_template_directory()
which returns the parent theme folder.The correct way to include files compatible for use with a child theme would be like this (docs here):
if( isset($zerif_latestnews_show) && $zerif_latestnews_show != 1 ): get_template_part( 'sections/latest_news' ); // NO trailing .php endif;
To the theme authors: Thanks for your great theme!
It would be even better if you could change all
include get_template_directory() ..
instances toget_template_part(..)
infront-page.php
in next release, thanks.To users: As a workaround for now also copy
front-page.php
to child-theme folder and apply the fix by hand where necessary.
- The topic ‘Child theme fix: use get_template_part instead include get_template_directory…’ is closed to new replies.