Remove sidebar from just one page.
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.
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!
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.
Thanks for the quick response.
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
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.]
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.
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!
@one with life: It is considered impolite to interrupt another poster’s thread. Please post your own topic.
- The topic ‘Remove sidebar from just one page.’ is closed to new replies.