Forums

Excluding sidebars from some posts/categories (3 posts)

  1. Richard Arghiris
    Member
    Posted 2 years ago #

    Hi,

    Sorry for the duplicate post, I orginally sent this to the wrong section.

    I'm trying to exclude my sidebar from a particular category of posts ('MAPS') so that I can fill the page with large googlemaps:

    http://interamericana.co.uk/2009/09/nicaragua/

    So far I have taken the following steps.

    First, I edited single.php;

    I changed:

    <div id="centercol">

    to:

    <div id="centercol" <?php if( in_category('MAPS') || is_category('MAPS') ) { echo 'class="fullwidth"'; } ?>>

    and then:

    <?php get_sidebar(); ?>

    to:

    <?php if( !in_category('MAPS') || !is_category('MAPS') ) { get_sidebar(); } ?>

    After, that I added the following to style.css:

    .fullwidth {
    width:865px;
    }

    However, as you can see, this has not worked.

    Any help would be very greatly appreciated.

    Thanks,

    Richard

  2. syncbox
    Member
    Posted 2 years ago #

    The easiest way to do this is to simply make a custom category template file for Maps that doesn't call the sidebar and that uses style rules IN the container (as inline declaration, which takes precedence over any external rules assuming same naming and therefore the same specificity)

    But, conditionally, you could put a couple of php statements changing the style properties in the main container:

    <?php
    if (is_catetgory('Maps')) {
    echo 'style="width:100%;"}'; }
    else {//do nothing, therefore the external style rule applies
    } ?>

    and use the same logic in the sidebar but set display:none.

    The first method is easier, but the second allows you to minimize the number of files necessary to maintain.

    HTH

  3. Richard Arghiris
    Member
    Posted 2 years ago #

    Hi,

    Thanks very much for the response, very helpful.

    I'm nearly there, but as I'm completely new to php (or programming in general), so I'm having some difficulties.

    I created a duplicate single.php and renamed it MAPS_single.php.

    Inside the duplicate I erased the lines about 'get sidebar'.

    Next I went into the original single.php and added these lines to the top:

    <?php
    $post = $wp_query->post;
    if ( in_category('MAPS') ) {include(TEMPLATEPATH . '/MAPS_single.php');}
    ?>

    I saved it. Now this has removed the sidebar for me, at least on the page, but I'm left with the sidebar trailing at the bottom page, along with all my video entries.

    http://interamericana.co.uk/2009/09/nicaragua/

    What am I missing?

    Any help would be great.

    Richard

Topic Closed

This topic has been closed to new replies.

About this Topic