Support » Fixing WordPress » Sidebar on a Separate page!

  • 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 - 16 through 30 (of 30 total)
  • somefool, You are a genious! It works! I owe you big time! Maybe I should give you a link on my page or something.
    And thanks, everyone else for helping.
    Now all I gotta do is go make it look neat and organized.

    Do they? OK, Id only every got errors trying that (I think) and of course if urls change (like youre domain) it doesnt work

    Somefool: the difference between include and require is how they deal if they can’t find the file. Include just gives a warning, require halts processing of the page and screams bloody murder.

    I wanted to include the code required to do this, in case anyone else has this problem. This is exactly how it is in my php file:

    <? error_reporting(E_ALL); ?>
    <? include(‘/wordpress/wp-blog-header.php’); ?>
    <? include(“/wordpress/wp-content/themes/default/sidebar.php”); ?>

    Yami, I never really understood the difference between the include and require thing.

    I knew it was something like that (stands to reason) as I said, I tend to use include for my theme.

    Id go with Yami’s suggestion of including a simple text file and see what happens. sounds like odd things are up.

    Or are you saying it works now?

    Yeah, it works now. It worked with “include” but not with “require.” Which is weird. I’ve never really used “require” either. I’ve always used “include” to get files.

    cool, must have been the wp-blog-header.php bit then, that basically makes the page a ‘WP Page’.

    Yeah, it was the ‘wp-blog-header.php’. At least I learned something new today, and didn’t give up on wordpress before I really got started with it.

    Hoorah for things working!

    To try and put this a little more coherently: include and require are the same function. They act in exactly the same way, except for when they can’t find the file they’re looking for. With include('/wrong/filename');, that file will simply be skipped and the rest of the page will be displayed without it. With require('/wrong/filename');, the PHP processor will stop trying to execute the file, and you’ll see something like “Fatal Error: can’t find file wrong/filename on line 236 of blah.php”.

    So you should be able to change include('/wordpress/wp-blog-header.php'); to require('/wordpress/wp-blog-header.php'); and not notice any difference. Or at least, that’s what the php manual says! I’m always reluctant to fiddle with these things once they’re working 😉

    Yami, It works with ‘require’ now. Maybe the first time around, the page didn’t refresh right or something. Occasionally, I have a problem when changing things on my site, they don’t immediately work.

    Thanks for the info on ‘require’ and ‘include.’

    I THINK (again with the ‘think’ because im not too sure on this) the wp-blog-header line should be the first line of the page due to what wp-blog-header does.
    If yours isnt then clearly im wrong 😉

    You can now use WP and WP plugin calls on that page, like recent posts and even use the loop on that page to bring up posts.

    Oooo the power of WP.

    It’s not the first line.
    I have:
    -site header
    -index
    -menu (with error reporting, header, and sidebar)
    -site footer

    I have many other lines of code before the ‘wp-blog-header’ line, and it’s working fine. It probably would be best to include the ‘wp-blog-header’ file in the header of my site though. Just in case I want to use it for something else later on.

    <STRONG>EDIT:</STRONG> Okay, bad idea. I didn’t work correctly in the ‘site header’ file. I had to put it back into the ‘menu’ file.

    You can now use WP and WP plugin calls on that page, like recent posts and even use the loop on that page to bring up posts.

    Oooo the power of WP.

    I’ll have to look into all of that. I can probably do some really neat things now, with that file included

    Anyone who may be interested in doing this, you can check out my website at: http://www.dark-autumn.com

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