Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sbryan

macrumors member
Original poster
Jun 6, 2007
96
0
So I'm trying to create a dynamic, editable sidebar in Wordpress and I can do it through a secondary loop.

However, because Wordpress creates pages like www.mysite.com/pagename, I'm not sure how to include the sidebar: www.mysite.com/sidebar through PHP or HTML.

Any ideas? Thanks guys.
 
If I'm understanding you, this is my solution. Use the server variable to get the root of your site, then give the path to the page. WordPress also has some variables for this I believe.
PHP:
include $_SERVER['DOCUMENT_ROOT'] . '/path2/page.php';
 
If I'm understanding you, this is my solution. Use the server variable to get the root of your site, then give the path to the page. WordPress also has some variables for this I believe.
PHP:
include $_SERVER['DOCUMENT_ROOT'] . '/path2/page.php';

Angelwatt, I did give that a try, but because I'm referencing the php document out-of-the-loop, it's not grabbing the information I want.

There may be another way besides creating a page in Wordpress, which I'm trying to do currently, but there seems to be no information on creating a dynamic (editable) sidebar.

Frustrating! Thanks for the reply.
 
First you need to set your functions.php file to register the 2 sidebars. If you don't have one, create a functions.php file and put it in your theme folder.
PHP:
<?php
if ( function_exists('register_sidebars') )
register_sidebars(2);
?>

Then create a second sidebar PHP file, call it sidebar2.php. To inset the second sidebar use
PHP:
<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>

You can use this to include any number of sidebars, and can have different pages with different sidebars, showing different information. Doing it this way will allow you to edit the sidebars in the admin through Widgets.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.