• Resolved carmeljune

    (@carmeljune)


    There is a mistake in the 5th line (array), can someone correct it for me please? Could be others but that’s the feed back I’m getting.

    function kish_picture_page_no_sidebar() {
     global $post;
     $cats=get_the_category($post->ID);
     foreach($cats as $cat) {
     if( $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');
Viewing 7 replies - 1 through 7 (of 7 total)
  • I think this is what you want:

    if( in_array($cat->cat_name,array("Birds", "Gardens", "Technology")) ) {
    Thread Starter carmeljune

    (@carmeljune)

    thanks vtxyzzy, this works now. Unfortunately it isn’t doing exactly what I wanted. I want the code to remove the sidebar on all of the category pages except the first one which is the home page. This code removes the sidebar from the 3 category pages, but I assume it is reading those names into the home page because it contains posts in those categories, and there fore removes its sidebar too.

    Maybe the code has to say if the page contains only posts in these categories, than remove side bar.

    Can someone translate that into php?

    Adding the is_category test will make the function effective only on the category pages:

    function kish_picture_page_no_sidebar() {
     global $post;
     if ( !is_category() ) return;
     $cats=get_the_category($post->ID);
    Thread Starter carmeljune

    (@carmeljune)

    Thank you vtxyzzy, now I have complete control over the sidebar.

    You are welcome! Now, please use the dropdown at top right to mark this topic ‘Resolved’.

    Thread Starter carmeljune

    (@carmeljune)

    thank you, thought I had done that … it is such a satisfying thing to do!

    Thread Starter carmeljune

    (@carmeljune)

    I had missed the ‘change’ button.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘php help please’ is closed to new replies.