WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to remove sidebar from multiple pages (25 posts)

  1. supermomwannabe
    Member
    Posted 3 years ago #

    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.

  2. orjense
    Member
    Posted 3 years ago #

    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.

  3. supermomwannabe
    Member
    Posted 3 years ago #

    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

  4. orjense
    Member
    Posted 3 years ago #

    Thank you so very much.

  5. orjense
    Member
    Posted 3 years ago #

    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

  6. inscoe2000
    Member
    Posted 2 years ago #

    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.

  7. causasui
    Member
    Posted 2 years ago #

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

  8. inscoe2000
    Member
    Posted 2 years ago #

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

  9. causasui
    Member
    Posted 2 years ago #

    got a tutorial on that? I wish this code worked ;)

  10. MrsSingleton
    Member
    Posted 2 years ago #

    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.

  11. causasui
    Member
    Posted 2 years ago #

    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.]

  12. esmi
    Forum Moderator
    Posted 2 years ago #

  13. causasui
    Member
    Posted 2 years ago #

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

  14. esmi
    Forum Moderator
    Posted 2 years ago #

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

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

  15. causasui
    Member
    Posted 2 years ago #

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

  16. esmi
    Forum Moderator
    Posted 2 years ago #

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

  17. causasui
    Member
    Posted 2 years ago #

    Ok thanks, and I just add that to the page.php in place of what I had correct?

  18. esmi
    Forum Moderator
    Posted 2 years ago #

    Yes

  19. MrsSingleton
    Member
    Posted 2 years ago #

    It worked this time. I was using the wrong number to identify the page number.

    THANK YOU!!

  20. causasui
    Member
    Posted 2 years ago #

    Put his code:

    <?php if( !is_page( array( 124, 379, 6 ) ) ) get_sidebar()){?>
    <?php get_sidebar(); ?>
    <?php } ?>

    Didnt work, it 500'd all my pages

    I also added JUST this:

    <?php if( !is_page( array( 124, 379, 111 ) ) ) get_sidebar());?>

    Same result, 500 all ages.

  21. causasui
    Member
    Posted 2 years ago #

    Ok, so I created a custom page template named nosidebar.php.
    I can choose it from the drop down when I add a page and it does not have a side bar.

    BUT, as I have read I still have the space bloacked out for the side bar. I copied the page.php code removed the sidebar code.

    Now, the page.php script is :
    <?php
    /*
    Template Name: nosidebar
    */
    ?>
    <?php get_header(); ?>
    <div class="span-16">
    <div id="content">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2 class="title"><?php the_title(); ?></h2>
    <div class="entry">
    <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(300,225), array("class" => "alignleft post_thumbnail")); } ?>
    <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

    <?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

    </div>
    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>
    </div>

    </div>
    <?php get_footer(); ?>

  22. causasui
    Member
    Posted 2 years ago #

    What do I do to call a css style that will give me control over this page container? It doesnt call container, even if I add a different content value it doesnt seem to work.

  23. causasui
    Member
    Posted 2 years ago #

    I got it, it was a template that called a span style, once I found the source css i could determine the proper width.

    Solved, learned a few things along the way also.

    ;)~

  24. mellowmoods
    Member
    Posted 2 years ago #

    Ok... I've been trying this code but the area that is the sidebar still is blocked out and the image in the main posting area is cut off. I want the sidebar completely removed and the posting area to take up that space so my image will show properly.

    Here is a link to the page where I am having issues.

    http://www.golivetoday.com/wp/?page_id=126

    Is there somewhere to designate how large the posting area is on one page? Or am I looking in the wrong direction?

  25. bestesolutionsBD
    Member
    Posted 2 years ago #

    I read the all comments. but i cant remove the side bar from my home page. anybody can help me??

Topic Closed

This topic has been closed to new replies.

About this Topic