__( 'Displays most popular posts based on the number of comments', 'themeidol-all-widget' ), ) ); } function register_scripts() { wp_register_style('stylish_popular_posts_style', THEMEIDOL_WIDGET_CSS_URL.'stylist-post-style.css'); } /** * Display the widget */ function widget( $args, $instance ) { extract( $args ); wp_enqueue_style('stylish_popular_posts_style'); /* Variables from the widget settings. */ $title = apply_filters('widget_title', esc_attr($instance['title']) ); $number = esc_attr($instance['number']); $checkbox = esc_attr($instance['checkbox']); $popularity=esc_attr($instance['popularity']); if($popularity=='visited') { $top_popular_posts = new WP_Query( array('ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => '_themeidol_view_count', 'order' => 'desc', 'paged' => 1)); //$top_popular_posts = new WP_Query('showposts=' . $number . '&meta_key=_themeidol_view_count&orderby=meta_value_num&order=DESC'); } else { echo "not"; $top_popular_posts = new WP_Query( array('ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'post_status' => 'publish', 'orderby' => 'comment_count', 'order' => 'desc', 'paged' => 1)); //$top_popular_posts = new WP_Query('showposts=' . $number . '&orderby=comment_count&order=DESC'); } if ($top_popular_posts->have_posts()) : echo $before_widget; /* Display the widget title. */ if ( $title ) echo $before_title . $title . $after_title; ?> have_posts()) : $top_popular_posts->the_post(); ?>

/>