I am currently using this code to extend WP_Widget_Recent_Posts, but I would like to exclude the field that gives the user the ability to show how many posts they want. I have a set number in my custom query to 4, so this box is useless and I don't want to confuse the user.
class JA_Recent_Work_Widget extends WP_Widget_Recent_Posts {
function __construct() {
$widget_ops = array('classname' => 'recent_work', 'description' => 'This widget will display 4 of your most recent works in the ART category Jay.');
$this->WP_Widget('ja_recent_work', 'Jay Alders Recent Work', $widget_ops);
}
function widget($args, $instance) {
extract( $args );
if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
$number = 10;
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
$r = new WP_Query('category_name=art&posts_per_page=4');
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
<?php if ($title) echo $before_title . $title . $after_title; ?>
<ul>
<?php while ($r->have_posts()) : $r->the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title()); ?>"><?php echo the_title(); ?></a>
<a href="<?php the_permalink() ?>"><?php echo the_post_thumbnail(); ?></li>
<?php endwhile; ?>
</ul>
<?php echo $after_widget ?>
<?php
wp_reset_postdata();
endif;
}
}
function my_recent_widget_registration() {
unregister_widget('WP_Widget_Recent_Posts');
register_widget('JA_Recent_Work_Widget');
}
add_action('widgets_init', 'my_recent_widget_registration');
