WordPress.org

Support

Support » Themes and Templates » How to remove sidebar on 1 page, and keep it on the others?

How to remove sidebar on 1 page, and keep it on the others?

Viewing 15 replies - 1 through 15 (of 31 total)
  • Nevermind. I remade the flash itself, instead.

    Hi AlxDesign. Unfortunately I didn’t see your post earlier. I see you have taken an alternate route but I’ll respond anyway in case you change your mind or for the benefit of others stumbling across this thread.

    You could accomplish this in a couple of different ways.

    1. Through the use of conditional tags OR
    2. By constructing a new template. Also read this. Scroll down about half way to Creating Your Own Page Templates.

    Option #1 – Your Gallery page will be using the page.php template file so look in there for the sidebar call. <?php get_sidebar(); ?> and adjust it to look like this …

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

    … where “x” is the ID number of that page.

    Option #2 – Build a new template and assign your Gallery page to use it instead of page.php This is not as hard as it sounds. You can make it a complete duplicate of page.php with the exception of the sidebar call of course.

    Be advised that whichever option you, or anyone else chooses, you may want to make further changes. Why? Because now that the sidebar is gone from a certain page you will have a rather strange looking empty space in its place. You would probably want to widen the content area of that page so that it takes up that extra space. You can take a look at the default Kubrick theme to see how this is implemented.

    Thanks for that LenK. I will surely use this function on my upcoming themes.

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

    That one was really nice and simple. Thanks again.

    This is great i am am having a bit of trouble though the forum which is the page in question does not stretch across the whole page.
    http://www.iamlizard.co.uk/?page_id=99

    any ideas?

    gavpedz I have the same problem you mention, how do you fix it???

    Lenk,

    Thank you so much for the solution. But, I don’t see a file under ‘wp-content’ in the name of my newly created page. I only see page.php and I suppose, this is NOT the page I should directly work with right. From what I read from your post, page.php is only a template. Please correct me if I am wrong. And another question I have is, where do I find the ID number of the page?

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

    ###UPDATE###

    Lenk,

    I found the answer myself. I am able to remove the sidebar on this page but, as others mentioned, I am not able to expand the content of this page to the full width of this page. Can you help me how could I do this?

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

    esmi

    @esmi

    Forum Moderator

    esmi

    @esmi

    Forum Moderator

    @gavpedz:

    i am am having a bit of trouble though the forum which is the page in question does not stretch across the whole page

    Your forum is inside a div with the class ‘Sheet’. This div (which incidentally seems to be defined twice in your css file) has a fixed with of 800px.

    Use the if/else where you render you container also…..

    I’d personally use this shorter version for the page conditional..

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

    Then do this for your DIV container…

    EXAMPLE DIV…
    <div class="SomeClassName">

    EXAMPLE WITH CONDITIONAL..
    <div class="<?php if (!is_page('x')) : ?>SomeClassName<?php else : ?>AnotherClassName<?php endif; ?>">

    Change the names of course… SomeClassName & AnotherClassName (purely example names).

    Set “AnotherClassName” to a larger width… which only applies it’s your particular page that doesn’t include the sidebar… 🙂

    t31os,

    I have no developer background. I presume that your ‘div class’ example is to expand the content to the whole page width. I also assume that I do this in the ‘page.php’ file? If not, please advise me where do I make these additions to.

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

    Where’s you’d normally have…
    <?php get_sidebar();?>

    You put the first condition…
    <?php if (!is_page('x')) : get_sidebar(); endif; ?>

    Then wherever you have the container/wrapper DIV….. like in the example (here it is again).
    <div class="myclass">

    Switch that for…
    <div class="<?php if (!is_page('x')) : ?>myclass<?php else : ?>myclasswider<?php endif; ?>">

    Basically when you on page X where X is the number or page name the sidebar is not shown and the class for the container DIV is switched to (in the new example) “myclasswider”, and uses the class “myclass” when showing the sidebar..

    It’s a little confusing when using an example name….

    So when the sidebar is shown…
    <div class"myclass">

    When the sidebar is not shown..
    <div class"myclasswider">

    You then accompany that with css to change width… (again another example)..

    .myclass {
    width:800px
    }
    .myclasswider {
    width:1000px
    }

    Not sure i can explain it any more simply, so hope that helps…

    Newbie Here,

    Here is my page.php code can someone help me, I tried to follow the example but Im just not that good with php or css, what Im trying to do is make a page without the sidebar included in it and to enlarge the page, any suggestions would be greatly appreciated?

    <?php get_header(); ?>
    <div class=”contentLayout”>
    <div class=”content”>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”Post”>
    <div class=”Post-body”>
    <div class=”Post-inner article”>
    <?php ob_start(); ?>
    <h2 class=”PostHeaderIcon-wrapper”>
    <img src=”<?php bloginfo(‘template_url’); ?>/images/PostHeaderIcon.png” width=”26″ height=”26″ alt=”PostHeaderIcon” />
    <span class=”PostHeader”>” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’, ‘kubrick’), the_title_attribute(‘echo=0’)); ?>”>
    <?php the_title(); ?>
    </span>
    </h2>
    <?php $metadataContent = ob_get_clean(); ?>
    <?php if (trim($metadataContent) != ”): ?>
    <div class=”PostMetadataHeader”>
    <?php echo $metadataContent; ?>

    </div>
    <?php endif; ?>
    <?php $icons = array(); ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php the_time(__(‘F jS, Y’, ‘kubrick’)) ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php _e(‘Author’, ‘kubrick’); ?>: “><?php the_author() ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (0 != count($icons)): ?>
    <div class=”PostHeaderIcons metadata-icons”>
    <?php echo implode(‘ | ‘, $icons); ?>

    </div>
    <?php endif; ?>
    <div class=”PostContent”>
    <?php if (is_search()) the_excerpt(); else the_content(__(‘Read the rest of this entry »’, ‘kubrick’)); ?>

    </div>
    <div class=”cleared”></div>
    <?php $icons = array(); ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php printf(__(‘Posted in %s’, ‘kubrick’), get_the_category_list(‘, ‘)); ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (!is_page() && get_the_tags()) : ?><?php ob_start(); ?>
    <?php the_tags(__(‘Tags:’, ‘kubrick’) . ‘ ‘, ‘, ‘, ‘ ‘); ?>
    <?php $icons[] = ob_get_clean(); ?><?php endif; ?>
    <?php if (!is_page() && !is_single()) : ?><?php ob_start(); ?>
    <?php comments_popup_link(__(‘No Comments »’, ‘kubrick’), __(‘1 Comment »’, ‘kubrick’), __(‘% Comments »’, ‘kubrick’), ”, __(‘Comments Closed’, ‘kubrick’) ); ?>
    <?php $icons[] = ob_get_clean(); ?><?php endif; ?>
    <?php if (0 != count($icons)): ?>
    <div class=”PostFooterIcons metadata-icons”>
    <?php echo implode(‘ | ‘, $icons); ?>

    </div>
    <?php endif; ?>

    </div>

    </div>
    </div>

    <?php endwhile; endif; ?>

    </div>
    <div class=”sidebar1″>
    <?php include (TEMPLATEPATH . ‘/sidebar1.php’); ?>
    </div>

    </div>
    <div class=”cleared”></div>

    <?php get_footer(); ?>

    I will pay for help with this, Im sure its pretty easy but I cant get it to work right?

    I’m trying to use this technique to add 3 columns under the header on my homepage but no where else

    i get half of this to work it creates the CSS for my 3 columns but it shows up on every page – any help would be great

    <div class=”<?php if (!is_page(‘home’)) : ?>contentL<?php else : ?>blank<?php endif; ?>”></div>
    <div class=”<?php if (!is_page(‘home’)) : ?>contentM<?php else : ?>blank<?php endif; ?>”></div>
    <div class=”<?php if (!is_page(‘home’)) : ?>contentR<?php else : ?>blank<?php endif; ?>”></div>

    .blank {
    width:0px;
    height: 0px;
    }

    .contentL{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-left: 40px;
    float:left;
    }

    .contentM{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-left: 20px;
    float:left;
    }
    .contentR{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-right: 20px;
    margin-left: 20px;
    float:left;
    }

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘How to remove sidebar on 1 page, and keep it on the others?’ is closed to new replies.