core function for child / parent theme file inclusion
-
Hello everbody,
while developing a parent / child theme setup for a multi-blog setup on one wp installation I had to work around some issues that came up while I was trying to include files from the child theme or -if not found there- from the parent theme.
Lets say we have a plugin that checks the template folder for a file to include in order to make it theme specific:
If u are not using a child / parent theme setup you would usually go and use the “get_template_directory()” function to get the path to the template in order to find and include the theme specific files. The Problem: If u have the child theme activated this function still points to the parent theme. So in order to include from your child theme you have to use a workaround like this: “dirname(get_bloginfo(‘stylesheet_url’))”.
In future releases I would like to see core functionality to …
- a) … dinstinguish between child / parent theme (like “get_parent_template_directory()” or “get_child_template_directory()” or “has_parent_template()” or whatever…
- b) … include files from child / parent themes like include_from_template(‘path & filename’). This function then checks wether the file exists in the child theme, if not it includes the parent theme version of that file.
I hope that makes sense!
- The topic ‘core function for child / parent theme file inclusion’ is closed to new replies.