esc_html__( 'Displays latest posts or posts from a choosen category.', 'hitmag' ), ) // Args ); } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { $defaults = array( 'title' => esc_html__( 'Latest Posts', 'hitmag' ), 'category' => 'all', 'viewall_text' => esc_html__( 'View All', 'hitmag' ) ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

$this->get_field_name('category'), 'selected' => $instance['category'], 'show_option_all' => 'Show all posts' ) ); ?>

id_base ); $category = ( isset( $instance['category'] ) ) ? absint( $instance['category'] ) : ''; $viewall_text = ( ! empty( $instance['viewall_text'] ) ) ? $instance['viewall_text'] : ''; // Latest Posts $latest_posts = new WP_Query( array( 'cat' => $category, 'posts_per_page' => 5, 'post_status' => 'publish', 'ignore_sticky_posts'=> 'true' ) ); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } hitmag_viewall_link( $category, $viewall_text ); ?>
have_posts() ) : while ( $latest_posts -> have_posts() ) : $latest_posts -> the_post(); if ( $hmp_count == 1 ) { ?>
', '' ); ?>