Title: php include not working in Header.php
Last modified: August 19, 2016

---

# php include not working in Header.php

 *  [jmwebguy](https://wordpress.org/support/users/jmwebguy/)
 * (@jmwebguy)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/)
 * Using WordPress MU.
 * I am trying to reference a file located in an individual blog’s blog.dir/files
   directory.
 * in header.php for the THEME, I added:
 *     ```
       <?php include (get_bloginfo('url') . '/files/test.html'); ?>
       ```
   
 * I know it’s the right path and a direct link to it works. What am I doing wrong?
   I need to be able to include the TXT that’s in that file.
    I’ll have this file
   in multiple blogs.dir/files folders.

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930358)
 * Try this…
 *     ```
       <?php
       $url=get_bloginfo('url');
       include($url. '/files/test.html'); ?>
       ```
   
 * I don’t think include likes the variable in it for some reason.
 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930389)
 * > I’ll have this file in multiple blogs.dir/files folders.
 * Why not just put it in one spot? Or will they all be different?
 *  Thread Starter [jmwebguy](https://wordpress.org/support/users/jmwebguy/)
 * (@jmwebguy)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930416)
 * Ipstenu, I tried that before I posted. Just tried again and it didn’t work. I
   can even do an echo write on that $url plus the file location and it points out
   the right location.
 * Andrea, They will all be different. I am putting ad tags in them and figured 
   this would be the easiest way. I will put one in the header and one in the footer.
 * I can’t figure out why this is so difficult. Even if I put the full url in the
   include, it doesn’t work. It’s like it’s ignoring it, yet other includes (in 
   the single.php) works.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930566)
 * > Even if I put the full url in the include, it doesn’t work.
 * … Wait a second.
 * What’s the FULL URL you’re trying to use? Is it like domain.com/subsite/files/
   test.html or domain.com/blogs.dir/2/files/test.html ?
 *  [ricozor](https://wordpress.org/support/users/ricozor/)
 * (@ricozor)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930739)
 * Hy,
 * I have also the same problem,
    Like **jmwebguy**, I want to includes php files
   witch are located in the parent directory of the Blog
 * I’ve tried <?php include (get_bloginfo(‘url’) . ‘/myfile.php’); ?> first and 
   <?php include (‘../../../../../myfile.php’); ?> next
 * the problem is the same.
 * the only include, seams to work, is when header.php and the other file are in
   the same directory.
 * Any idea ?
 *  [ricozor](https://wordpress.org/support/users/ricozor/)
 * (@ricozor)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930740)
 * I have found the solution right here :
    [http://wordpress.org/support/topic/include-php-files-at-absolute-urls?replies=5](http://wordpress.org/support/topic/include-php-files-at-absolute-urls?replies=5)
 * you have to write your incude like this :
    <?php include(ABSPATH . “../myfile.
   php”); ?>
 * ABSPATH is the root of your wordpress blog
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years, 1 month ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930741)
 * You can also use `get_bloginfo( 'wpurl' )` 🙂 You were VERY close with your ‘
   url’ call!
 * `<?php include( get_bloginfo( 'wpurl' ) . "/myfile.php"); ?>`
 *  [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930742)
 * `include()` with a URL will only work under certain specific circumstances on
   a server (and even then, IIRC, if you are including a PHP file, it will include
   the parsed version rather than the raw PHP code). `include()` and `require()`
   statements should always use paths (/var/www/…) rather than URLs if you want 
   them to work consistently and properly.
 * EDIT – You can read a little more about what I mentioned above by reading the
   second paragraph below Example #2 on the [PHP doc page for the `include()` function](http://us.php.net/manual/en/function.include.php).

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘php include not working in Header.php’ is closed to new replies.

## Tags

 * [blogs.dir](https://wordpress.org/support/topic-tag/blogs-dir/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 8 replies
 * 5 participants
 * Last reply from: [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/php-include-not-working-in-headerphp/#post-1930742)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
