__( 'Display Marquee of Post Categories.', 'best-shop' ), ) ); } public function widget( $args, $instance ) { $max_items = ( ! empty( $instance['max_items'] ) ) ? absint( $instance['max_items'] ) : 6; $title = ( ! empty( $instance['title'] ) ) ? wp_strip_all_tags( $instance['title'] ) : ''; $category = ( ! empty( $instance['category'] ) ) ? wp_strip_all_tags( $instance['category'] ) : 0; $args = array(); if( $category == -1 ){ $args = array ( 'post_type' => 'post', 'posts_per_page'=> $max_items, 'post_status' => 'publish' ); } else if ($category == -2) { $args = array ('post_type' => 'post', 'posts_per_page' => $max_items , 'meta_key' => 'my_post_viewed', 'orderby' => 'meta_value_num', 'order' => 'DESC' , 'post_status' => 'publish' ); } else if ($category == -3) { $args = array ('post_type' => 'post', 'posts_per_page'=> $max_items, 'order' => 'DESC', 'post_status' => 'publish' ); } else { $args = array ( 'post_type' => 'post', 'posts_per_page'=> $max_items, 'cat' => $category ); } $loop = new WP_Query($args ); ?> 'name', 'parent' => 0 )); $categories = get_categories( $args ); $category_list = ''; $item = new best_shop_cat(); $item->term_id = '-1'; $item->name = '-- All Categories --'; array_unshift($categories , $item); $item = new best_shop_cat(); $item->term_id = '-2'; $item->name = 'Popular Posts'; array_unshift($categories , $item); $item = new best_shop_cat(); $item->term_id = '-3'; $item->name = 'Latest Posts'; array_unshift($categories , $item); foreach ( $categories as $cat ) { $selected =''; if(($cat->term_id) == $category){ $selected ='Selected=selected'; } $category_list = $category_list.''; } ?>