Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #786754

    I am going to need to make some changes to the Product Page template and how it is coded in order to properly display some promotions on our site. The problem is I have configured my Child Theme, which works great for all PHP / CSS files in the root directory of the child theme, but it will not properly load subdirectory replacements in the child theme. I would rather make changes to Child Theme files than Parent theme (as updates to the theme can blow them away).

    My include in my child theme functions.php for Enque of Child Theme

    
    /* Enqueue Child Theme */
     
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
     
        $parent_style = 'enfold-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
     
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }

    Like I said, the above code works great for root directory replacements in the child theme such as header.php, style.css and functions.php
    However, I will need to be able to change files in config-woocommerce/config.php

    #786761

    Hey pcmichiana,

    Please see the following for a guide to solving your issue:

    http://ignaciogondra.com/2016/03/24/wordpress-overwrite-sub-file-child-theme/

    Best regards,
    Jordan Shannon

    #786771

    Jordan
    Thank you for your response! I saw that solution at a few other places and I’ve been trying to implement it into my Child Theme functions.php file over the past couple of hours with no luck. I keep getting an internal server error 500 when it happens. I’m assuming it’s because the function is pointing to the wrong sub-directory when it is called for some reason.

    Here is my code:

    /* Grab Custom PHP Overwrites In Child Theme Subdirectories */
    require_once( get_stylesheet_directory() . '/config-woocommerce/config.php' );

    I also attempted it your way

    /* Grab Custom PHP Overwrites In Child Theme Subdirectories */
    require get_stylesheet_directory() . '/config-woocommerce/config.php';

    I confirmed I have an exact copy of the /config-woocommerce/config.php from the parent theme in my child theme.
    Any thoughts on this? I’m not sure where else the function could be pointing too other than my child theme directory for that function call.

    • This reply was modified 6 years, 11 months ago by pcmichiana.
    #787001

    Hi,

    Have you tried just recreating the file structure within the child theme?

    Best regards,
    Jordan Shannon

    #787167

    Jordan
    Yes I have, that was my original strategy. Here are my file structures

    Parent Theme: Enfold
    enfold/functions.php
    enfold/style.css
    enfold/header.php
    enfold/config-woocommerce/config.php

    File structure for the child theme

    Child Theme: Enfold-Child
    enfold-child/functions.php
    enfold-child/style.css
    enfold-child/header.php
    enfold-child/config-woocommerce/config.php

    The files in the root directory of the child theme work perfectly (functions.php, style.css, header.php) but any time I attempt a child theme overwrite of a subdirectory (config-woocommerce/config.php) it does not work.

    • This reply was modified 6 years, 11 months ago by pcmichiana.
    #787174

    Ok so apparently it’s something specific with the theme or the file I am calling.
    If I create a separate file in the config-woocommerce subdirectory called phpinfo.php and then run a basic phpinfo(); call then the require_once function call works if I call config-woocommerce/phpinfo.php – the issue comes back if I switch back to config-woocommerce/config.php
    I also attempted to copy the entire parent theme into the child them in the hopes that other includes in those files may be picked up… but no luck.
    Any other thoughts on this? I’m still plugging away at it.
    As a side note, if Enfold is truly a “eCommerce” theme as advertised then there really needs to be a way to edit the product page. That is the single most important landing page for split testing / eCommerce optimization.

    #787584

    Hi,

    I’m sorry but you can only override default WordPress template files in the child theme, not the config files from the theme. What specific changes are you trying to implement in the product page? I’m sure you can use the woocommerce hooks and filters to achieve that.

    // https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/

    Best regards,
    Ismael

    #788942

    Ismael
    You nailed it!
    This opens many opportunities for me. Thank you for all your help on this! I was able to use hooks to add my custom code functionality to the product page and even move content around.
    Excellent theme guys, keep up the great work.

    #788950

    Hi,

    We are glad you were able to get this figured out. If you need additional help, please don’t hesitate to contact us here in the forums.

    Best regards,
    Jordan Shannon

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Is It Possible To Have Subfolders Overwrite Parent Theme PHP In Child Theme?’ is closed to new replies.