Support » Fixing WordPress » How to remove sidebar from multiple pages

  • Resolved supermomwannabe

    (@supermomwannabe)


    I found a code for removing the sidebar from one specific page, but what is the code for removing the sidebar from multiple pages, for the page template? I’d rather do that than find a plug in.

Viewing 15 replies - 1 through 15 (of 24 total)
  • You found a code for removing a sidebar from one page? Would you share the code? I ve been looking for help with that.
    Thanks in advance.

    It had me edit the page template and find:
    <?php get_sidebar(); ?>

    and adjust it to look like this …

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

    where it says x you need to put in the page number of the page you want it removed from…you can find that by going to your list of pages and mousing over the pages, then look at the base of your screen to see the url – the page number is at the end of that url

    Thank you so very much.

    Thanks again, that work- the sidebar is gone. But I still have the grey area showing. Would you know how to stretch the content of the page? I’m using the page for a forum.
    androidnews

    inscoe2000

    (@inscoe2000)

    I love the code for removing the sidebar on a page, but what if I want to remove it from more that one page. I tried

    <?php if (is_page(‘x’, ‘y’)) : ?>

    But it only worked on the x page.

    Any word on this, I really need per page ability to remove side bar.

    I ended up making custom page templates with variations on what sidebars I wanted showing. Worked great.

    got a tutorial on that? I wish this code worked ๐Ÿ˜‰

    I tried the fix above and it did not work for me to remove the sidebar from the one page. I also would like any tutorial on custom page templates. All I really want, though is to remove the sidebar from that one page.

    It works for sure.

    Here is tutorial.

    Modify your page.php file

    In your WordPress Editor, go to Appearance / Editor and click on page.php. Scroll down to the bottom of the file where you will see the line of code that displays your sidebar:

    <?php get_sidebar(); ?>

    Replace that one line with this:

    <?php if ( !( is_page(โ€˜696โ€˜) ) ) { ?>
     <?php get_sidebar(); ?>
     <?php } ?>

    Note that you will need to replace the red 696 post ID number above with your Post ID number.

    Save the file. Youโ€™re done.

    [Please post code snippets between backticks or use the code button.]

    esmi

    (@esmi)

    Forum Moderator

    Got to be a way to use PHP in the page.php to define what pages you want to exlude the side bar from?

    esmi

    (@esmi)

    Forum Moderator

    <?php if( !is_page( array( 42, 54, 6 ) )  ) get_sidebar());?>

    http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    Do I add this code to the above or delete the above and replace with this?

    esmi

    (@esmi)

    Forum Moderator

    It’s meant as a replacement but you must add in your own page ids.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘How to remove sidebar from multiple pages’ is closed to new replies.