Here is a simple widget to get you started. You should be able to tweak it to get the effects you want.
class recent_pages extends WP_Widget {
public function __construct() {
// widget actual processes
parent::__construct(
'recent_pages', // Base ID
'recent pages', // Name
array( 'description' => __( 'Show the recent pages', 'foo'))
// Args
);
}
public function widget( $args, $instance ) {
global $post;
echo $args['before_widget'];
if (!empty($instance['title'])) {
$title = $instance['title'];
echo $args['before_title'].$title.$args['after_title'];
}
echo '<ul class="recent_pages">';
$pargs = array(
'post_type' => 'page',
'posts_per_page' => 10,
'date_query' => array(
'after' => $post->post_date
),
'order' => 'ASC',
);
$pages = new WP_Query($pargs);
if ($pages->have_posts()) {
while($pages->have_posts()) {
$pages->the_post();
echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li> <br>';
}
}
wp_reset_query();
echo '</ul>';
echo $args['after_widget'];
}
}
add_action(
'widgets_init',
function(){
register_widget( 'recent_pages' );
}
);
It works mostly by using the date_query
argument to WP_Query
. Check the Codex for details of how that operates.