网站经常有些老文章更新,但是却没有提示,导致用户不知道或者需要重新置顶文章,这里给wordpress添加一个显示最近更新过文章的调用方法。
wordpress调用最近更新文章列表
1、将以下代码添加到主题的 functions.php里
function recently_updated_posts( n u m = 10 , num=10, num=10,days=7) {
if( !$recently_updated_posts = get_option(‘recently_updated_posts’) ) {
query_posts(‘post_status=publish&orderby=modified&posts_per_page=-1’);
$i=0;
while ( have_posts() && i < i< i<num ) : the_post();
if (current_time(‘timestamp’) - get_the_time(‘U’) > 606024*$days) {
$i++;
$the_title_value=get_the_title();
r e c e n t l y u p d a t e d p o s t s . = ′ < l i > < a h r e f = " ′ . g e t p e r m a l i n k ( ) . ′ " t i t l e = " ′ . recently_updated_posts.='<li><a href="'.get_permalink().'" title="'. recentlyupdatedposts.=′<li><ahref="′.get