'andrina_gallery_widget', 'description' => __('Gallery Widget can be used a portion of gallery in any widget area','andrina-lite'), ); parent::__construct('Smart_gallery_widget', __('Smart Gallery Widget','andrina-lite'), $widget_ops); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } $_max = $instance['numb_post']; // $_max = 9; // $r = new WP_Query("showposts=$_max&what_to_show=posts&post_status=inherit&post_type=attachment&orderby=menu_order ASC, ID ASC&post_mime_type=image/jpeg,image/gif,image/jpg,image/png"); $attachment_args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'showposts' => $_max, 'post_status' => null, 'orderby' => 'menu_order ID' ); $attachments = get_posts($attachment_args); if ($attachments) { echo '
'; } echo $args['after_widget']; } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form($instance) { // outputs the options form on admin $title = !empty($instance['title']) ? $instance['title'] : __('Gallery', 'andrina-lite'); $numb_post = !empty($instance['numb_post']) ? $instance['numb_post'] : 9; ?>