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.
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?
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.
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 ?
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 ?
I have found the solution right here :
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
You can also use get_bloginfo( 'wpurl' )
🙂 You were VERY close with your ‘url’ call!
<?php include( get_bloginfo( 'wpurl' ) . "/myfile.php"); ?>
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.