logo

$10
widget logic plugin question

I use this
is_single()
to have a widget show up on my single page template. I have a category with the id of "1", and I do not want the widget to show up on the single template page. Any solution?

Rick Bible | 05/14/10 at 2:32am | Edit


(2) Possible Answers Submitted...

  • avatar
    Last edited:
    05/14/10
    2:42am
    Utkarsh Kukreti says:

    is_single() && !is_category(1)


    Try this
    is_single() && !in_category(1)

    Previous versions of this answer: 05/14/10 at 2:40am

    • 05/14/10 2:38am

      Rick Bible says:

      this does not work, right idea and direction,

  • avatar
    Last edited:
    05/14/10
    2:44am
    Oleg Butuzov says:

    on template

    if (is_single() && !in_array(1, get_post_categories_ids()) && (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) ){
    // here will be your widgets.
    }


    in functions php



    function get_post_categories_ids(){
    global $post;
    $categorylist = get_the_category($post->ID);
    if (count($categorylist) == 0) return array();
    $cat = array();
    foreach($categorylist as $categ){
    $cat[] = $categ->term_id;
    }
    return $cat;
    }

    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    }

    Previous versions of this answer: 05/14/10 at 2:37am | 05/14/10 at 2:38am | 05/14/10 at 2:43am | 05/14/10 at 2:44am

This question has expired.





Current status of this question: Completed