• david

    (@dskirk)


    I have several successful sites with child themes, but when a theme has a php file in a subdirectory that I’ve modified, placing my modification in child them directory, including new subdirectory, doesn’t work. The theme always opens the original. I set up child themes as defined at https://codex.wordpress.org/Child_Themes, including a functions.php file, but no luck.

    Here is an example of one of my functions.php files:

    <?php
    /* 
     * Child theme functions file
     * 
     */
    function himalayas_child_enqueue_styles() {
    
    	$parent_style = 'himalayas-style'; //parent theme style handle 'himalayas-style'
    
    	//Enqueue parent and chid theme style.css
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); 
    	wp_enqueue_style( 'himalayas_child_style',
    	    get_stylesheet_directory_uri() . '/style.css',
    	    array( $parent_style ),
    	    wp_get_theme()->get('Version')
    	);
    }
    add_action( 'wp_enqueue_scripts', 'himalayas_child_enqueue_styles' );
    /* get_stylesheet_directory() . '/inc/widgets/widgets.php'; */
    ?>

    I think I need to add something like
    get_stylesheet_directory_uri() . '/inc/widgets/widgets.php',
    somewhere, but I don’t know where. Everything you see here I copied from others, as I do not know PHP. Any help will be appreciated. Thanks.

Viewing 1 replies (of 1 total)
  • Prashant Singh

    (@prashantvatsh)

    Hi @dskirk,

    One can only override template files in the child theme and if it is not a template file then you can not override it. If it is not working then certainly widgets.php cannot be overridden. Please let me know which theme you are using?

    Thanks

Viewing 1 replies (of 1 total)

The topic ‘child theme with php files in subdirectories’ is closed to new replies.