'astro_widget',
'description' => 'Displays a image from NASA Astronomy Picture of the Day',
);
parent::__construct( 'astro_widget', 'Astronomy Daily', $widget_ops );
}
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
// outputs the content of the widget
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
}
$count = $instance['count'];
$size = $instance['size'];
$args = array(
'posts_per_page' => $count,
'post_type' => 'astro',
'orderby' => 'date'
);
$astro = get_posts( $args );
foreach ($astro as $post) { ?>
= get_the_post_thumbnail( $post->ID, $size ); ?>
= $post->post_title; ?>
How to register new image size? Visit this link