Support » Themes and Templates » Can I remove the sidebar this way?

  • I am hoping to remove my sidebar on everything besides my home page. After reading a few different post I think I have a game plan, but wanted to run it by you all to make sure that I am not missing anything.

    1) Create a home.php
    2) Copy everything thats in index.php into home.php
    3) Remove <?php get_sidebar(); ?> from index.php and page.php

    If I am reading these other posts correctly this should remove the sidebar on everything besides my home page. Am I correct or dead wrong? 🙂

    Is there anything else that these changes will have an effect on?

    Any info you can give me would be much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I actually went a different way… I decided that I only need to remove the sidebar from one page. So I replaced the current tag that calls the sidebar with:

    <?php if (is_page(‘X’)) : ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    X being the page ID number that I want to exclude the side bar from. But I came up with a slight different problem. How do I reclaim the space where the side bar was located for the body of the page?

    Your approach is correct but of course now you have this ugly empty space where the sidebar used to be. 🙂 That’s easy to fix. You simply have to adjust your stylesheet. Look at the default Kubrick theme to see how it accomplishes this. Notice the content DIV on index.php and single.php uses different classes?

    <div id="content" class="narrowcolumn">

    <div id="content" class="widecolumn">

    Study the differences between these 2 in the stylesheet. It’s not that hard to wrap your head around it.

    Awesome thanks for the info!!

    I actually just got it going before you posted. What I ended up doing is using that same if/else statement for two different style sheets. So if page ID is X then use this style sheet, else use the standard. Changed the width on the new style sheet to 100%.

    See any long term issues with that?

    See any long term issues with that?

    Nah. You can use all the stylesheets you want. They aren’t actually downloaded on a visitor’s browser until needed so it won’t affect load time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can I remove the sidebar this way?’ is closed to new replies.