• I’m using the P2 theme and I’d like the front page to have the sidebar, but not the other pages. But when the sidebar is gone I would like the page to fill the same width as the page does WITH the sidebar (736px).

    Currently when you hide the sidebar in the Theme options, it hides it on ALL pages and reduces the width of the site to 706px.

    Thanks!

    I’m using P2 v1.1.5, btw.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Okay, I’m a little new to all of this but here’s what I did. It’s a little scary but it seemed to work.

    I’m guessing you probably know your way around things a bit but I’ll explain it step by step in case someone else needs it. I certainly could have used it!

    Basically what I did was move the

    <?php get_sidebar() ?>

    line from the header.php file to the index.php and page.php files.

    1. First duplicate page.php and add this code to the very top:

    <?php
    /*
    Template Name: no sidebar page
    */
    ?>

    You can put anything you want for the “no sidebar page” part but I thought that was easiest and save it as “no sidebar page.php” (or whatever) and upload this to your ftp in your P2 theme folder.

    2. Next, in header.php, delete the last line:

    <?php get_sidebar() ?>

    So the bottom now looks something like this:

    <?php endif; ?>
    			<a class="secondary" href="<?php bloginfo( 'url' ); ?>/"></a>
    	</div>
    
    </div>
    
    <div id="wrapper">

    3. Then add the line you deleted:

    <?php get_sidebar() ?>

    …to both index.php and page.php, just beneath the line:

    <?php get_header() ?>

    So the top now looks something like this in the index.php file:

    <?php get_header() ?>
    
    <?php get_sidebar() ?>
    
    <div class="sleeve_main">
    	<?php if ( p2_user_can_post() && !is_archive() ) : ?>
    		<?php locate_template( array( 'post-form.php' ), true ) ?>

    And like this in the page.php file:

    <?php get_header() ?>
    
    <?php get_sidebar() ?>
    
    <div class="sleeve_main">
    
    	<div id="main">
    		<h2><?php the_title(); ?></h2>

    4. Then go to the page you want to change to not having any sidebars.

    Under page attributes you will now see a drop down menu that says “Template”. Just select your new “no sidebar page” template and there you go.

    Like I said, no offense is meant if I’ve oversimplified things but maybe someone else can use it. ??

    I hope this helps!

    Best wishes,
    Kristen

    Wow, I don’t think Speckltoe ever thanked you for this.

    Looking through your well thought out steps, I can tell this is the right code for exactly what he wanted to do.

    I don’t even have P2 but I did want to say thank you for taking the time to care.

    Thanks Kristen!

    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide Sidebar on certain pages but keep width’ is closed to new replies.