WordPress.org

Ready to get started?Download WordPress

Forums

How to Remove Sidebar From All Pages Except Home Page? (4 posts)

  1. neutrino14
    Member
    Posted 2 years ago #

    HI. I'm using Magazine Basic theme (physicsdatabase.com). So I want to remove the Sidebar from all pages except the front page. I've tried using the conditional statement stuff, but I'm not sure where to put this code:
    <?php if (is_page('x')) : ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    I've tried putting this to page.php and what happened was that all my pages displayed huge sidebars in the centre of the page. I also tried doing that custom template stuff. I created a new php file in cpanel, but it doesn't appear when I create a new page ( actually there's no dropdown menu with an option to choose template at all). So I think I should edit this code in footer.php:

    </div>
    <?php
    $loc = pbt_theme_option('sidebar_location');
    if($loc==2 || $loc==4) {
    get_sidebar(); // calling the First Sidebar
    }
    if(pbt_theme_option('sidebar_width2')!=0 && $loc!=3) get_sidebar( "second" ); // calling the Second Sidebar
    ?>
    </div>
    <!-- begin footer -->
    ...

    BUt I'm not sure. COuld somedoby help me? Cheers

  2. Parker
    Member
    Posted 1 year ago #

    Sorry that you havent had an answer until now... IDK if you have had this question answered by now. But, here is my siggestion!

    Just install the "Dynamic Widgets" plugin!

    It uses the sidebar area's you already have, and you can change what sidebar widgets (or, in your case, the sidebar in general) show on what page.

    Hope this helps!

  3. kaformedia
    Member
    Posted 1 year ago #

    Here are easy steps:

    1. COPY everything from the index.php into notepad
    2. CREATE a new file named page-home.php and paste everything from index.php and remove the sidebar and make changes you want for homepage also add this on top:

    /**
     * Template Name: Home Page
     */

    3. Name the php file page-home.php

    4. Go to Pages in wordpress and select the 'Home Page' template and publish (It will override anything you do in the post, tags, etc.)

    5.Go into WordPress > Settings > Reading Settings
    and select 'Home Page' for front page and your done.

  4. Parker
    Member
    Posted 1 year ago #

    You may want to do kaformedia's idea with a child theme, so that the page-home.php file doesn't get deleted in the next update

Topic Closed

This topic has been closed to new replies.

About this Topic