How to add another folder to template hierarchy
-
Hi there,
I´m trying to overwrite the archive-portfolio template. I´m using the Business Pro-Theme by SEOTHEMES. This child theme already has a file called archive-portfolio.php. Now I want to overwrite this file with my own custom archive-portfolio.php so that I don´t have to risk being overwritten with the next theme update.
As far as the plugin loads the template hierarchy and checks if a template is located in the theme folder before loading the template from the plugin directory there must be a way to add another location which should be checked first…like a subfolder in the child theme called “custom-templates”.
I already tried a lot of different things including different versions of the template_include filter….like that:
add_filter( 'template_include', 'be_template_chooser' ); function be_template_chooser( $template ) { if ( be_return_archive_section() ) //$template = get_query_template( 'archive-' . be_return_archive_section() ); $template = get_stylesheet_directory_uri() . '/custom/archive-' . be_return_archive_section() ; return $template; }I tried to put the code in the functions.php but it seems that it doesn´t really overwrite the code in the plugin (maybe because being loaded to late).
Does anybody know how to achieve the desired result? In the end the idea is to have a setup similar to a grand-child theme.
Any help is really appreciated!
The topic ‘How to add another folder to template hierarchy’ is closed to new replies.