• Resolved carmeljune

    (@carmeljune)


    I got this terrific bit of code from https://www.kisaso.com/technology/thesis-customization-selected-category-posts-without-sidebar/

    function kish_picture_page_no_sidebar() {
     global $post;
     $cats=get_the_category($post->ID);
     foreach($cats as $cat) {
     if($cat->cat_name=='Pictures') {
     if (is_single()) {?>
     <style>
     #sidebars { display: none; border: none; }
     #container {width:940px}
     #content  {width:100%; background}
     #content_box { background:none; }
     #content_box img{max-width:850px;height:auto;}
     </style>
     <?php }
     }
     }
    }
    add_filter('thesis_hook_before_html', 'kish_picture_page_no_sidebar');

    I can modify it in 2 ways.
    by removing if (is_single())
    it will remove the side bar from all of the ‘pictures’ category pages

    by removing all of the following and one bracket at the end, it will remove the side bar from all category pages, which is what I’m after.

    if($cat->cat_name=='Pictures') {
     if (is_single())

    However, (there’s always a however!) I want the sidebar on my home page.

    Can someone please tell me how to write this code so it says

    except for home page, remover sidebar from all category pages.

    failing this, can it say:

    if the category is pictures, gardens or birds,
    then remove sidebar.

    Thanks heaps you lovely php person, very grateful.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter carmeljune

    (@carmeljune)

    wish I’d put php code in the heading, might have got more attention!

    Thread Starter carmeljune

    (@carmeljune)

    this is the complete code

    /*
    function kish_picture_page_no_sidebar() {
     global $post;
     if ( !is_category() ) return;
     $cats=get_the_category($post->ID);
     foreach($cats as $cat) {
     if( in_array($cat->cat_name,array("Birds", "Gardens", "Technology")) ) {
     {?>
     <style>
     #sidebars { display: none; border: none; }
     #container {width:940px}
     #content  {width:100%; background}
     #content_box { background:none; }
     #content_box img{max-width:850px;height:auto;}
     </style>
     <?php }
     }
     }
    }
    add_filter('thesis_hook_before_html', 'kish_picture_page_no_sidebar');
    */

    Thread Starter carmeljune

    (@carmeljune)

    resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘sidebar on category pages’ is closed to new replies.