When you say it doesn’t work – does it return any error messages? Does it not include the file at all, or does it just choke on parts of it? Try setting your error reporting level to E_ALL, see if it returns anything helpful.
Also, see this thread.
Okay, I tried the error reporting thing. If this is the correct way to do it:
<? error_reporting(E_ALL); ?>
Nothing shows up. And that’s the same thing that was happening before.
Hm. Now that I look at your include() statement a little more closely… I think you’re supposed to use single quotes, not double quotes. Could that be it?
Okay, tried the single quote thing. Nothing changed. Plus, I use “double quotes” for all of my other includes.
Here’s the code:
<div id=”navcontainer”>
<div id=”lmain”>
<h3 class=”main”><span>Main</span></h3>
</div>
<? include(“http://dark-autumn.com/wordpress/wp-content/themes/default/sidebar.php”); ?>
<? error_reporting(E_ALL); ?>
</div>
Oh, you need to set your error reporting before attempting the include, or it won’t apply.
I dont think it should have http://, I think it should just be the path to the file example in my home.php I have
include “header.php”;
if it were an absolute path it’d be
include “/usr/home/somefool/public_html/wp13/wp-content/themes/sflwa3c/header.php”;
it should be similarly set up in your WP admin screens, under options for uploading files.
Im pretty sure thats right.
There is no such thing as “…/sidebar.php”, there should only be two dot’s.
Try <? include (“../sidebar.php”); ?>
Regards
Sorry, I should point out that mine is with my header file, the theory should be fine with sidebar – just in case, sorry.
Okay. I moved the error reporting above the include. Still no errors.
I changed the path. And now I have an alignment problem, but the sidebar isn’t showing up. It’s kind of like it’s including the file, but the content of “sidebar.php” isn’t showing up. It shows up correctly on the wordpress pages, but not here.
Also, if I just type in the url of “…sidebar.php” nothing comes up. Just a blank page.
It might be worth mentioning that even if you get this working, if the sidebar uses WP specific calls and the page youre trying to include it in ISNT a WP page I dont think itll work.
I think you need to add
require(ABSPATH . ‘wp-blog-header.php’);
too the top of the page (or change the path so it gets to the wp-blog-header.php file in WP.
I think – this is certainly how I got similar things working for my gallery.
There is no such thing as “…/sidebar.php”, there should only be two dot’s.
Try <? include (“../sidebar.php”); ?>
———————————————————
I wasn’t giving the actual include statement. I just didn’t type out the whole path. That’s what the “…” is for.
If youre using http:// I dont think thatll work.
Remove it, refresh the page and itll pretty much tell you what the path is because itll give you a big error.
I tried:
<? require(ABSPATH . ‘/wordpress/wp-blog-header.php’); ?>
I think that’s the way to do it, right?
And now, my whole menu has dissapeared from the page.
If youre using http:// I dont think thatll work.
——————————————————————-
I’ve removed the (http://).
I’m still getting no errors.
try just
<? include(‘/wordpress/wp-blog-header.php’); ?>
and see what happens
If you STILL dont get any errors then something odds happening as it should cry blue murder that it cant find the file.
the require bit was from the code that WP uses, im not sure of the difference between require and include but in this case I think include is the one.
Also, try putting some sort of text in the side bar like “XXXX–SIDEBAR–XXXX” – id suggest at the top – just so you know its getting the right file, I often use this temporarily for troubleshooting.
Includes through http should work – have you tried this with other files? Can you successfully include a plain text file from your theme directory using this method?