Customising templates and child themes
-
A “plus one” for sinrho’s comment at https://www.ads-software.com/support/topic/child-theme-template-directory
When overriding the templates in themes, it doesn’t work if the theme is a child theme. get_template_directory() returns the parent theme directory. To ensure you get the right theme directory even with a child theme directory you need to use get_stylesheet_directory()
--- media-category-library.php.orig 2014-12-14 20:31:24.366038111 +0000 +++ media-category-library.php 2014-12-14 20:31:55.565816808 +0000 @@ -331,7 +331,7 @@ *@since 0.6 */ function get_template_file( $file ) { - $template = get_template_directory() . '/' . $this->get_plugin_dir() . '/' . $file; + $template = get_stylesheet_directory() . '/' . $this->get_plugin_dir() . '/' . $file; if ( ! file_exists( $template ) ) $template = $this->get_plugin_path() . '/views/' . $file; return $template; }
https://www.ads-software.com/plugins/media-category-library/
- The topic ‘Customising templates and child themes’ is closed to new replies.