$size ) add_image_size( 'cat_post_thumb_size' . $id, $size[0], $size[1], true ); } } class CategoryPosts extends WP_Widget { function CategoryPosts() { parent::WP_Widget(false, $name='Category Posts'); } /** * Displays category posts widget on blog. */ function widget($args, $instance) { global $post; $post_old = $post; // Save the post object. extract( $args ); $sizes = get_option('jlao_cat_post_thumb_sizes'); // If not title, use the name of the category. if( !$instance["title"] ) { $category_info = get_category($instance["cat"]); $instance["title"] = $category_info->name; } // Get array of post info. $cat_posts = new WP_Query("showposts=" . $instance["num"] . "&cat=" . $instance["cat"]); // Excerpt length filter $new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";"); if ( $instance["excerpt_length"] > 0 ) add_filter('excerpt_length', $new_excerpt_length); echo $before_widget; // Widget title echo $before_title; if( $instance["title_link"] ) echo '' . $instance["title"] . ''; else echo $instance["title"]; echo $after_title; // Post list echo "
()
" name="get_field_name("excerpt_length"); ?>" value="" size="3" />