BLDR Theme – Override template in subdirectory
-
Hello!
INTRO
I am trying to edit a template file calledbldr-services.php
but i cannot get it to override the parent file. As far as i can tell, it comes down to the fact that in the parentfunctions.php
, the call for the file has the pathget_template_directory()
instead ofget_stylesheet_directory()
. If i change the call to useget_stylesheet_directory()
then i am able to override the template successfully in my child theme. The problem there is that when the theme updates, i will lose the changes. I need to find a way to make it a permanent fix/change.DETAILS
I am using the free theme called BLDR. I have created a child theme and it works as it should. When i try to override the filetheme-dir/widgets/bldr-services.php
by placing a copy of it inchild-theme-dir/widgets/bldr-services.php
it does not override. Even if i place the file in the root of the child theme it doesn’t work.After looking in the parent themes
functions.php
i found that the path to file uses the template directory and not the stylesheet directory. So when i try to override the template, it reads the parent theme directory and not the child theme directory. Here is the code from the parentfunctions.php
:/** * Load the front page widgets. */ if ( function_exists('siteorigin_panels_activate') ) { require get_template_directory() . "/widgets/bldr-clients.php"; require get_template_directory() . "/widgets/bldr-projects.php"; require get_template_directory() . "/widgets/bldr-testimonials.php"; require get_template_directory() . "/widgets/bldr-services.php"; require get_template_directory() . "/widgets/bldr-home-news.php"; require get_template_directory() . "/widgets/bldr-cta.php"; require get_template_directory() . "/widgets/bldr-columns.php"; }
If i change this to the following code below, then i am able to override the file by placing a copy in my child theme:
/** * Load the front page widgets. */ if ( function_exists('siteorigin_panels_activate') ) { require get_stylesheet_directory() . "/widgets/bldr-clients.php"; require get_stylesheet_directory() . "/widgets/bldr-projects.php"; require get_stylesheet_directory() . "/widgets/bldr-testimonials.php"; require get_stylesheet_directory() . "/widgets/bldr-services.php"; require get_stylesheet_directory() . "/widgets/bldr-home-news.php"; require get_stylesheet_directory() . "/widgets/bldr-cta.php"; require get_stylesheet_directory() . "/widgets/bldr-columns.php"; }
Problem here is when the theme updates, the
functions.php
loses the changes.Is there a way to override this code in my child themes
functions.php
?
Is there maybe a work around for a situation like this?I really appreciate any responses. I have looked all over for a solution, but none that i could find are accurate to this specific problem.
- The topic ‘BLDR Theme – Override template in subdirectory’ is closed to new replies.