• Resolved linkit

    (@linkit)


    I am trying to exclude any sidebat from showing in one of my categories and have this so far but it doesnt seem to work??

    <?php if ( is_category(‘6’) ) { !(get_sidebar()); } ?>

    Can someone help please?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello

    Your best bet is to create a category template for said category and omit the call to the sidebar within it.

    Hope it helps. ??

    In the default theme’s archive.php I replaced:
    <?php get_sidebar(); ?>

    with

    <?php if (!is_category('6') ) { (get_sidebar()); } ?>

    and it seemed to return the result you desire.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    While MichealH’s trick will work, I really think a category template is a better way to go. Copy the file you’re working with (category.php? index.php?) to “category-6.php”. Then edit that file and remove the get_sidebar call from it entirely. Done and done.

    The reason I like a template better is because it allows you to customize a lot without using tricky if statements to determine things. This leaves you with cleaner and easier to work with code. Templates are also slightly faster, although that’s just theoretical more than anything else.

    The votes are in, and BPartch and Otto42, describe the best solution.

    Thread Starter linkit

    (@linkit)

    Michaels statement didnt work as I have other statements going on:

    <?php if (!is_category(‘6’) ) { (get_sidebar()); }
    <?php if ( is_category(’18’) ) { include (‘sidebar1.php’); }
    else if ( is_category(’41’) ) { include (‘sidebar2.php’); }
    else if ( is_category(’37’) ) { include (‘sidebar3.php’); }
    else if ( is_category() ) { get_sidebar(); } ?>

    I will try the template route..thanks

    What I did was to create an other sidebar template called: “sidebar_3” and include this code in the “category_3” template.

    <?php include (TEMPLATEPATH . “/sidebar_3.php”); ?>

    Of course inside the loop.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to exclude sidebar from a certain category’ is closed to new replies.