Support » Fixing WordPress » different sidebar on different pages

  • I have created a second page template (imaginatively called page2) that is identical to the standard template.
    I have also managed to get a second sidebar option viewable from the widgets and changed the widgets used on sidebar2.
    But I cannot get page2 to use sidebar2.
    The site is The news page, which shows the posts, is using page2. All the other pages use the standard template.
    How do I enable page2 to use sidebar2?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Page two needs to load sidebar2. Did you add it to sidebar.php or did you create sidebar2.php and is it being loaded/called in the page2.php?

    Not sure how I got where I am, as I had to try so many things. I did create a sidebar2.php but it is a mirror of the original sidebar.
    When you use the widgets, however, there are now two options, sidebar1 and sidebar2 but I suspect these having nothing to do with the php files as there is no sidebar1.php
    I was also trying other bits from this docs page and created a sidebar-custom file and tried using the

    <?php if ( function_exists (‘register_sidebar’)) {
    register_sidebar (‘custom’);
    } ?>

    code but that just threw out the whole site.
    The page2 does include:

    <?php include (‘sidebar2.php’); ?>

    but that is obviously not enough.

    page2 is a template I guess? Otherwise all sidebars should be called from the index.php. And you can use a if statement to make it appear on a certain page such as the home page.

    Sorry, that meant nothing to me. What code do I paste where?

    Sorry. Been away for a while. A sidebar can be included on a index or page. Another way is to give a certain page a style / lay-out through a template which can be attached to it in the dashboard..

    after creating your sidebar2 the next step is to call it from your template page. imagine that sidebar1.php goes in page1.php with the default code <?php get_sidebar(); ?>
    then, your sidebar2.php should be called into your page2.php with the code <?php include (TEMPLATEPATH . ‘/sidebar2.php’); ?> (instead of <?php get_sidebar(); ?> )

    I tried a number of different formulations but the best I coudl get was the page to begin with

    Warning: Division by zero in /home7/thezebra/public_html/wp-content/themes/r755/page2.php on line 8

    Warning: Division by zero in /home7/thezebra/public_html/wp-content/themes/r755/page2.php on line 8

    Warning: include(php) [function.include]: failed to open stream: No such file or directory in /home7/thezebra/public_html/wp-content/themes/r755/page2.php on line 8

    Warning: include() [function.include]: Failed opening ‘php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home7/thezebra/public_html/wp-content/themes/r755/page2.php on line 8

    Any thoughts on where I went wrong and what the code should have been?

    Any luck on this one?

    I found some good information here in the Docs section, some of which has already been posted here.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘different sidebar on different pages’ is closed to new replies.