How to disbale sidebar in inner Pages/Posts as I require only in Homepage?

Discussion in 'WordPress' started by freaky316, Jun 20, 2012.

  1. #1
    I want to display sidebar only in the homepage of my wordpress site and I wanted to disable sidebar in all the inner pages/posts/links.
    Please advise me how to achieve this factor.

    Thanks a lot.
     
    freaky316, Jun 20, 2012 IP
  2. Imposter

    Imposter Peon

    Messages:
    169
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There is this this line of code which loads sidebar.php:

    <?php get_sidebar(); ?>
    PHP:
    If you delete it from your files page.php and single.php there should not be any sidebar displayed when viewing pages or posts.
     
    Imposter, Jun 20, 2012 IP
  3. cons1t

    cons1t Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    or perhaps comment it out.
     
    cons1t, Jun 20, 2012 IP
  4. xtrapunch

    xtrapunch Greenhorn

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    @Imposter has given you the right solution. Delete the
    <?php get_sidebar(); ?>
    PHP:
    from single.php (displays posts) and page.php (displays pages) template files in your WordPress theme folder.

    Alternatively, edit the sidebar.php file. You need to wrap the entire content of the sidebar.php in a conditional tag.

    <?php 
    if ( is_home() || is_front_page() ) { ?>
    
    YOUR ENTIRE CONTENT
    
    <?php } ?>
    PHP:
     
    xtrapunch, Jun 21, 2012 IP