WordPress child theme files in subdirectory not overriding

I am modifying a WordPress theme using a child theme. In my child theme folder, I have created a folder called “includes” (just like the parent) and have made edits to the content-post.php, content-single.php and content-single-portfolio.php files. I have added to the functions.php file in the child folder:

require_once( get_stylesheet_directory() . 'includes/content-post.php' );
require_once( get_stylesheet_directory() . 'includes/content-single.php' );
require_once( get_stylesheet_directory() . 'includes/content-single-portfolio.php' );

This causes a 500 internal error and I’m not sure why.

Read More

Reference:
http://codex.wordpress.org/Child_Themes

http://systemspecialist.net/2013/04/16/add-customized-files-includes-folder-to-wordpress-child-theme/

I also tried this solution and get the same 500 error:
WordPress Child Theme including includes files

Related posts

1 comment

  1. get_stylesheet_directory()

    Returns an absolute server path (eg:
    /home/user/public_html/wp-content/themes/my_theme), not a URI.

    your code probably converted to absolute url like

    /home/user/public_html/wp-content/themes/my_themeincludes/content-single-portfolio.php

    get_stylesheet_directory() should always be followed by forward slash

    require_once( get_stylesheet_directory() . '/includes/content-post.php' );

    Your best option is to check the error log, Most 500 error message are related to php timeout, specially if the site was previously working fine before you did any php modification.

    You can also try doing something like this one by one for each file

    //Checking if file exist
    if ( file_exists( get_stylesheet_directory() . '/includes/content-post.php') ) {
        //Require file if it exist, 
        require_once( get_stylesheet_directory() . '/includes/content-post.php' )
    } else {
        /* Echo something if file doesn't exist, if the message wasn't displayed and you still get 500 error then there's some wrong on the php file above*/
        _e('File not found');
    }
    

Comments are closed.