I've attempted to install a theme on a Wordpress installation in a Windows development environment, which will be synced through Git with a production environment in CentOS.

The theme has a file called loader.php which appends get_template_directory() with a subdirectory path that uses forward slashes. As you can probably guess, this results in a directory separator mismatch that has broken my entire site.

I know the proper answer to this is to use get_template_directory_uri(), but I'd like to avoid editing the parent theme as much as possible in order to reduce incompatibility with future updates, and instead keep any edits to the child theme (which of course does not have loader.php).

Is there another workaround that I could possibly use to fix this that doesn't involve editing theme files and maintains compatibility with both Windows and CentOS?

The code in question:

if ( ! defined( 'THEME_PATH' ) )    define( 'THEME_PATH',   trailingslashit( 
get_template_directory() ) );
require_once THEME_PATH . 'includes/theme.options.php';

This is returning:

Fatal error: require_once(): Failed opening required 'C:\Users\<name>\Sites\dev/wp-content/themes/<themename>/includes/theme.options.php' (include_path='.;C:\php\pear') in C:\Users\<name>\Sites\dev\wp-content\themes\<themename>\fw\loader.php on line 62​

  • Can you give an example from the code of what you're talking about? I'm not sure what get_template_directory_uri() has to do with the issue, since there aren't really any situations where those functions are interchangeable. Is get_template_directory() using incorrect slashes, or the path after it? Commented Feb 14, 2019 at 15:01
  • 1
    URLs on Windows use a forward slash too, so this shouldn't break anything.
    – fuxia
    Commented Feb 14, 2019 at 15:01
  • Updated with the code.
    – pidgezero
    Commented Feb 14, 2019 at 15:06
  • 1
    You don't need to change the slashes for folders and files on Windows vs non-Windows, PHP quite happily accepts / for all of them regardless of platform. Even then, URLs always use /
    – Tom J Nowell
    Commented Feb 14, 2019 at 15:06
  • @JacobPeattie I suppose either one could be considered incorrect, the function returns backslashes and the hardcoded appended directory uses forward slashes. Ideally I'd like the function to always return forward slashes so that it doesn't give the error shown above.
    – pidgezero
    Commented Feb 14, 2019 at 15:31

1 Answer 1


Tom’s comment is consistent with my experience. But even if the mixed slashes are an issue, you’re not going to be able to fix it in any way other than by editing the parent theme.

This is because the string that contains the forward slash is not being passed through any WordPress function with a filter. If the theme used the more modern get_theme_file_path() function, then you would be able to fix the issue with this line of code in your child theme:

add_filter( 'theme_file_path', 'wp_normalize_path' );

The only other thing I would suggest is making absolutely sure that the file the theme is trying to load actually exists in that directory. An incomplete install or copy could have left you with missing files, which would cause this issue regardless of OS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.