• I am in the process of setting up my first site with WordPress 2.1. I have created a separate page template for some “static” pages that are the front end of my site. This page template is a copy of the default theme template, that I am trying to modify. I have also made a copy of the sidebar.php file (I am using the default theme) that would be used only by the “static” pages. However, I can’t find anywhere in the documentation where there is mentioned a way to “point” a page template towards an alternative “sidebar.php” file (mine is named “site_sidebar.php”.

    Can this be done and I just haven’t found the documentation, or am I attacking this issue in entirely the wrong way?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Setting up a page and positioning it is not the same as creating a new template. The difference is that a template can include the php functionality you need. Best consult codex on creating a template. HTH.

    Thread Starter globetrotterdk

    (@globetrotterdk)

    Many thanks. That was the hint I needed ?? Cooool.

    Hint? Heck that was the best I could do………..

    There are two ways to do this, first is the noob, hack way (sadly that is all I was able to do) and the second is the neat way.

    1. There is already a template for posts and one for pages (which both call the same sidebar) so to have a different side bar on a page you just need to create a new sidebar.php (i called mine pagesidebar.php, which includes the stuff you want) and then edit the page.php and change…
    <?php get_sidebar(); ?>
    to
    <?php include (‘pagesidebar.php’); ?>
    Note: sidebar.php is a core WP file which is why it is included using get_sidebar. That won’t work with a custom page so you need to use include instead.

    2. The much neater way of doing it is to use Conditional Tags (see https://codex.www.ads-software.com/Conditional_Tags) in your sidebar.php so that if the page is a post the sidebar includes items D, E and X but if it is a page it uses C, X and Z.

    I shall leave it to you to choose between the light side and the dark side.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Alternative sidebar to go with “static” page template?’ is closed to new replies.