esc_html__( 'WOODMART Recent Posts', 'woodmart' ), // Widget Backend Description 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your site’s most recent Posts.', 'woodmart' ), 'slug' => 'woodmart-recent-posts', ); // create widget $this->create_widget( $args ); } // Output function function widget( $args, $instance ) { if ( $this->is_widget_preview() ) { return; } extract($args); echo wp_kses_post( $before_widget ); if( ! empty( $instance['title'] ) ) { echo wp_kses_post( $before_title ) . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . wp_kses_post( $after_title ); } // Get the recent posts query. $offset = ( isset( $instance['offset'] ) ) ? $instance['offset'] : 0; $posts_per_page = ( isset( $instance['limit'] ) ) ? $instance['limit'] : 5; $orderby = ( isset( $instance['orderby'] ) ) ? $instance['orderby'] : 'date'; $category = ( isset( $instance['category'] ) ) ? $instance['category'] : 'all'; $order = ( isset( $instance['order'] ) ) ? $instance['order'] : 'DESC'; $thumb_height = ( isset( $instance['thumb_height'] ) ) ? $instance['thumb_height'] : 45; $thumb_width = ( isset( $instance['thumb_width'] ) ) ? $instance['thumb_width'] : 45; $thumb = ( isset( $instance['thumb'] ) ) ? $instance['thumb'] : true; $comment_count = ( isset( $instance['comment_count'] ) ) ? $instance['comment_count'] : true; $date = ( isset( $instance['date'] ) ) ? $instance['date'] : true; $query = array( 'offset' => $offset, 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'order' => $order ); if ( 'all' !== $category ) { $query['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $category ) ); } $posts = new WP_Query( $query ); ?> have_posts() ): ?>
/>
/>
/>