Ok, to display the latest posts you use default Recent Posts widget.
You can see it here: Appearance -> Widgets
This widget has no settings and is fine for getting started, you can install any plugin which will add a more sophisticated widget to your site, you just need to search for: Recent Posts Widget
I found the following:
And more…
Just go to plugins and add it to your site, then select it in widgets and customize accordingly
Edit
Change the post title relative to the date (if a month has not passed since the publication)
function wpb_lastvisit_the_title ( $title, $id ) {
if ( is_singular() || get_post_type( $id ) != 'post' ) return $title;
$p = get_post( $id );
$now = new DateTime();
$date = DateTime::createFromFormat(get_option( 'date_format' ), $p->post_date);
if($date){
$interval = $now->diff($date);
$days = $interval->d;
// If a month has not passed, show the label
if($days <= 30) {
$title .= ' <span class="new-article">New</span>';
}
}
return $title;
}
add_filter( 'the_title', 'wpb_lastvisit_the_title', 10, 2);
By tag:
function wpb_lastvisit_the_title ( $title, $id ) {
if ( is_singular() || get_post_type( $id ) != 'post' ) return $title;
$tag_ids = wp_get_post_tags($id, array('fields' => 'ids'));
// tag with name - new
$tagId = get_term_by('slug', 'new', 'post_tag') -> term_id;
if(in_array($tagId, $tag_ids)) {
$title .= ' <span class="new-article">New</span>';
}
return $title;
}
add_filter( 'the_title', 'wpb_lastvisit_the_title', 10, 2);