'widget_akella_recent_posts', 'description' => esc_html__( 'Use this widget to list your recent posts. Well-suited to display in the sidebar.', 'akella' ), 'customize_selective_refresh' => true, ) ); } /** * Output the HTML for this widget. * * @access public * * @param array $args An array of standard parameters for widgets in this theme. * @param array $instance An array of settings for this widget instance. */ public function widget( $args, $instance ) { global $post; $number = empty( $instance['number'] ) ? 4 : absint( $instance['number'] ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Recent Posts', 'akella' ) : $instance['title'], $instance, $this->id_base ); // Params for our query. $query_args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true ); if ( is_singular() ) { $query_args['post__not_in'] = array( $post->ID ); } // The Query. $recentPosts = new WP_Query( $query_args ); if ( $recentPosts->have_posts() ) : echo wp_kses_post( $args['before_widget'] ); ?>