How to remove the wp sidebar in a page.

Discussion in 'WordPress' started by magiclouie, Apr 16, 2010.

  1. #1
    Hi DP members,

    I only want to see the sidebar in my posts and not in my other pages.

    Please help me on how to remove the sidebar in wp pages.

    Thanks in advance.
     
    magiclouie, Apr 16, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Delete <?php get_sidebar(); ?> from the theme files index.php, archive.php, search.php and page.php. It only has to be in the file single.php.
     
    s_ruben, Apr 16, 2010 IP
  3. magiclouie

    magiclouie Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks a lot s_ruben.

    More power to you!
     
    magiclouie, Apr 16, 2010 IP
  4. entrenewbie

    entrenewbie Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you actually only want to remove it from single.php, not index.php.... if you remove <?php get_sidebar()?> from index.php it will remove the sidebar from your main page.
     
    entrenewbie, Apr 16, 2010 IP
  5. magiclouie

    magiclouie Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Thank you for this entrenewbie and this really makes sense.
     
    magiclouie, Apr 16, 2010 IP
  6. Blasingame

    Blasingame Peon

    Messages:
    761
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    How old is your blog? do you have many post? if you have more then a few post and you remove your side bar you will need no longer have to worry if is there or now. You will conveniently create a 404 master piece. I would buy a nice 404 template for that...
     
    Blasingame, Apr 16, 2010 IP
  7. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #7
    If the
    <?php get_sidebar(); ?>
    PHP:
    is in a common template like footer, removing it will make it disappear from all the pages, post, index..

    Use this code to replace the above code.

    <php if (is_single()) { <?php get_sidebar(); ?> } ?>
    PHP:
    It'll show the sidebar on single posts only.

    To show it on only index and single post, use this code
    <php if (is_single() || is_home() ) { <?php get_sidebar(); ?> } ?>
    PHP:
     
    Abhik, Apr 16, 2010 IP