• Resolved kbam7

    (@kbam7)


    Hello!

    INTRO
    I am trying to edit a template file called bldr-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 parent functions.php, the call for the file has the path get_template_directory() instead of get_stylesheet_directory(). If i change the call to use get_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 file theme-dir/widgets/bldr-services.php by placing a copy of it in child-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 parent functions.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.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘BLDR Theme – Override template in subdirectory’ is closed to new replies.