确定,要显示最新帖子,请使用默认设置Recent Posts 小部件。
您可以在此处看到:Appearance -> Widgets
此小部件没有设置,可以开始使用,您可以安装任何插件,将更复杂的小部件添加到您的站点,您只需搜索:Recent Posts Widget
I found the following:
及更多。。。
只需转到插件并将其添加到您的站点,然后在小部件中选择它并进行相应的自定义
<小时/>
Edit
更改
post title 相对于
date (如果自发布以来还没有过一个月)
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);
按标签:
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);