• I’ve created a second sidebar for my theme and call it in using <?php include(TEMPLATEPATH."/sidebar2.php");?>

    I’m trying to add a third sidebar (that will sit below the second one), but I want it to be different on every page. For the home page, I named the “new” sidebar “sidebar_home.php” and, I can get it to work using <?php include(TEMPLATEPATH."/sidebar_home.php");?> in page.php.

    I don’t want to have to use a different page template for every page, so I was trying to call it in using <?php include(TEMPLATEPATH."/sidebar_".$pagename.".php");?> in page.php. But I’m getting an “include not found” kind of message (the PHP one). Specifically, it says Warning: include(path/to/wp-content/themes/mytheme/sidebar_.php) [function.include]: failed to open stream: No such file or directory in path\to\wp-content\themes\mytheme\page.php on line 40

    I’d have sworn I got that to work once, briefly, on one page, but now it’s not. Any ideas? Thanks in advance.

  • The topic ‘$pagename in sidebar name’ is closed to new replies.