'ocius-featured-post',
'description' => esc_html__('Displays Featured Post in Home Page. Place it in Home Widget Area Top.', 'ocius'),
);
parent::__construct('ocius-featured-post', esc_html__('Ocius Featured Post', 'ocius'), $opts);
}
function widget($args, $instance)
{
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
$cat_id = !empty($instance['cat']) ? $instance['cat'] : '';
$post_number = !empty($instance['post-number']) ? $instance['post-number'] : 5;
$query_args = array(
'post_type' => 'post',
'cat' => absint($cat_id),
'posts_per_page' => absint($post_number),
'ignore_sticky_posts' => true
);
$query = new WP_Query($query_args);
if ($query->have_posts()) :
while ($query->have_posts()) :
$query->the_post();
?>
'name', 'hide_empty' => 0, 'id' => $this->get_field_id('cat'), 'name' => $this->get_field_name('cat'), 'class' => 'widefat', 'taxonomy' => 'category', 'selected' => absint($instance['cat']), 'show_option_all' => esc_html__('Show Recent Posts', 'ocius') ); wp_dropdown_categories($cat_args); ?>