different sidebar on different pages (9 posts)

  1. whealie
    Posted 7 years ago #

    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 http://www.the-zebra.com. 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?

  2. Rhand
    Posted 7 years ago #

    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?

  3. whealie
    Posted 7 years ago #

    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.

  4. Rhand
    Posted 7 years ago #

    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.

  5. whealie
    Posted 7 years ago #

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

  6. Rhand
    Posted 7 years ago #

    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..

  7. Jenny Beaumont
    Posted 7 years ago #

    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(); ?> )

  8. whealie
    Posted 7 years ago #

    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?

  9. starschreck
    Posted 6 years ago #

    Any luck on this one?

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


Topic Closed

This topic has been closed to new replies.

About this Topic