On my set-up, there is the regular website which consists of a header and content (both printed from separate PHP files located in domain.com/includes/) and a Wordpress blog based in a subdirectory (domain.com/blog/).

I want to include domain.com/includes/header.php on the main Wordpress skin. I have tried require_once, include, specifying the ABSPATH in the wp-config, and various other techniques but none of them have worked for me.

Printing the header.php contents to Wordpress skin is vital and there is no compromise for it in my workflow.

I would greatly appreciate any advice as to how I can get this script working, whether it be through a plugin or some edit to the core files, without having to change the location of domain.com/includes/header.php.

Thanks in advance.

  • Hi J. Watkins, could you provide more details on what you've tried already (and why it didn't work)? – kraftner Jun 11 '14 at 12:48
  • Hi @kraftner. Thanks for the response. I've tried adding the include through <?php include('/includes/header.php'); ?> as well as explicitly stating the full path with domain.com at the beginning. I've tried a few different functions: include, require_once as I saw somebody suggest on a similar question, as well as including the ABSPATH. <?php include('/includes/header.php'); ?> works fine on the main site and prints the contained HTML without error. – J. Watkins Jun 11 '14 at 12:55
  • What paths have you tried for include? – kraftner Jun 11 '14 at 12:58
  • I've tried using both absolute and relative paths as well as just specifying the containing folder. – J. Watkins Jun 11 '14 at 12:59

Using the domain name in the path won't work; you're not trying to specify a URL, but a path to a file, be it relative or not. Using include(ABSPATH . '../includes/header.php' ) should work.

/includes/header.php doesn't work because the location of the blog folder doesn't is not the root folder (/), but most likely a few levels down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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