• I’ve been looking through the forums for a simple answer to this, and I just couldn’t find it. First off, I’ve had a website for quite sometime, and I don’t want to completely change all of the content over to wordpress. I basically just want to use wordpress to blog. What I want to do is take the sidebar and pull it into another page outside of the /wordpress directory. I would like the sidebar to be included with my pre-existing menu. I’ve tried:
    <? include(“…/sidebar.php”); ?>
    but it doesn’t seem to work. I have all the directories correct and everything. I’m not particularly skilled at php, but I can usually get what I want done. This seems to be bugging me though. I would greatly appreciate any help. And I can provide any other information that may be needed to help.

Viewing 15 replies - 1 through 15 (of 30 total)
  • 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.

    Thread Starter Justin Tadlock

    (@greenshady)

    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?

    Thread Starter Justin Tadlock

    (@greenshady)

    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(“https://dark-autumn.com/wordpress/wp-content/themes/default/sidebar.php&#8221;); ?>

    <? 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 https://, 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.

    Thread Starter Justin Tadlock

    (@greenshady)

    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.

    Thread Starter Justin Tadlock

    (@greenshady)

    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 https:// 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.

    Thread Starter Justin Tadlock

    (@greenshady)

    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 https:// I dont think thatll work.
    ——————————————————————-
    I’ve removed the (https://).

    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?

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘Sidebar on a Separate page!’ is closed to new replies.