__( 'Display latest_posts with featured image and Meta', 'business-store' ), ) ); } // Creating widget front-end public function widget( $args, $instance ) { $title = ( ! empty( $instance['title'] ) ) ? strip_tags( apply_filters( 'widget_title', $instance['title'] ) ) : __( 'Recent Posts', 'business-store' ); $max_items = ( ! empty( $instance['max_items'] ) ) ? strip_tags( $instance['max_items'] ) : '5'; $hide_title = ( ! empty( $instance['hide_title'] ) ) ? strip_tags( $instance['hide_title'] ) : false; // before and after widget arguments are defined by themes echo $args['before_widget']; if (!$hide_title) echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title']; // This run the code and display the output business_store_lite_get_latest_posts($max_items); // echo $args['after_widget']; } // Widget Backend public function form( $instance ) { $title = ( ! empty( $instance['title'] ) ) ? strip_tags( apply_filters( 'widget_title', $instance['title'] ) ) : __( 'Recent Posts', 'business-store' ); $max_items = ( ! empty( $instance['max_items'] ) ) ? strip_tags( $instance['max_items'] ) : '5'; $hide_title = ( ! empty( $instance['hide_title'] ) ) ? strip_tags( $instance['hide_title'] ) : false; // Widget admin form ?>
id="get_field_id( 'hide_title' )); ?>" name="get_field_name( 'hide_title' )); ?>" />
'; $args = array( 'post_type' => 'post', 'ignore_sticky_posts' => 1 , 'posts_per_page' => absint($max), 'numberposts' => absint($max) , 'orderby' => 'date', 'order' => 'DESC'); $latest_posts_query = new WP_Query($args); while ($latest_posts_query->have_posts()) : $latest_posts_query->the_post(); $i=1; ?>