WordPress.org

Ready to get started?Download WordPress

Forums

$pagename in sidebar name (1 post)

  1. Kodiak3000
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic