__('A widget that show popular posts base on the comment number', 'gdl_back_office'))); } // Output of the widget function widget( $args, $instance ) { global $gdl_widget_date_format, $blog_port_widget_size; extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); $post_cat = $instance['post_cat']; $show_num = $instance['show_num']; if($post_cat == "All"){ $post_cat = ''; } // Opening of widget echo $before_widget; // Open of title tag if ( $title ){ echo $before_title . $title . $after_title; } // Widget Content wp_reset_query(); $current_post = array(get_the_ID()); $custom_posts = get_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat, 'orderby'=>'comment_count', 'post__not_in'=>$current_post) ); if( !empty($custom_posts) ){ echo "
"; foreach($custom_posts as $custom_post) { ?>
ID ); $thumbnail = wp_get_attachment_image_src( $thumbnail_id , $blog_port_widget_size ); if( $thumbnail_id ){ echo '
'; echo ''; $alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true); if( !empty($thumbnail) ){ echo ''. $alt_text .''; } echo ''; echo '
'; } ?>

post_title, 'gdl_front_end'); ?>

ID ); if( $comments_num > 1 ){ $output = str_replace( '%', number_format_i18n($comments_num), __('% Comments','gdl_front_end') ); echo $output; }else if( $comments_num == 1 ){ _e('1 Comment','gdl_front_end'); }else{ _e('No Responses.','gdl_front_end'); } ?>
"; } // Closing of widget echo $after_widget; } // Widget Form function form( $instance ) { if ( $instance ) { $title = esc_attr( $instance[ 'title' ] ); $post_cat = esc_attr( $instance[ 'post_cat' ] ); $show_num = esc_attr( $instance[ 'show_num' ] ); } else { $title = ''; $post_cat = ''; $show_num = '3'; } ?>