WordPress.org

Ready to get started?Download WordPress

Forums

Remove sidebar from just one page. (7 posts)

  1. Theadum
    Member
    Posted 2 years ago #

    Hello all!

    After hours of searching the forums, I managed to get the answer to the above question.

    On my page.php file I edited the <?php get_sidebar(); ?> to:

    <?php if (!is_page('forum')) : get_sidebar(); endif; ?>

    As you can see, the page I didn't want the side bar on is the Forum page.

    This worked a treat. However I was then left with a huge blank space where the sidebar use to be (a problem that occurred for most people). To get around this I added the following to my page.php file:

    <div class="<?php if (!is_page(forum)) : ?>content<?php else : ?>nosidebar<?php endif; ?>">

    And created the nosidebar attribute in my style.css sheet.

    This has worked fantastically. The home page has the side bar, the forum doesn't and is correctly scaled across the entire page.

    However.

    When I click on any other page other than home or forum, the side bar is centered and under all the content. Why is this...?

    Please let me know if you need anymore information or code.

    Thank you in advance!

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    have you really just added this line?
    because, if you have, you would need to close the div somewhere.

    you might be able to change the css class in an existing div with the conditional code.

    please post a link to your site to illustrate the problem.

  3. Theadum
    Member
    Posted 2 years ago #

    Thanks for the quick response.

    The website page that is working is http://www.brfcfans.com/forum/ and http://www.brfcfans.com

    If you click register, login etc you'll notice the side bar is under the content and centered. This site has only been up a couple of days so still learning!

    I've put that code under <div id="content">.

    So looks like this:

    <div id="content" >
    <div class="<?php if (!is_page(forum)) : ?>content<?php else : ?>nosidebar<?php endif; ?>">
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post single" id="post-<?php the_ID(); ?>">
    <div class="title">
    <h2><a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>

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

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    have you added a closing div as well?

    try and use the http://validator.w3.org/ to check if the </div> is missing in the pages.

  5. one with life
    Member
    Posted 2 years ago #

    Hello, I have a problem with full width content on a single post page... I followed "The Sweeper" instruction and turned off the sidebar of "journal' category off but know the sidebar is not there but the content is still 570px instead of 100% = 900px Can someone help me please? Here is the link to the page: http://www.onewithlife.ca/letter-to-adya/

    THANK YOU SO MUCH!

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    @one with life: It is considered impolite to interrupt another poster's thread. Please post your own topic.

  7. one with life
    Member
    Posted 2 years ago #

    oh sorry i am very new to all this... and i fix it already. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic