[不花钱站长]:从免费域名开始[0元] Oracle永久免费VPS[0元] VPS环境搭建免费脚本[0元] 秒变大盘挂载免费网盘[0元] 小白免费采集器1天500W[0元] CF免费DNS+CDN服务[0元]
[零基础网赚]:撸本站免费源码[0元] 网站强引免费蜘蛛法[0元] 图片视频文件免费存储[0元] 外链轻松发布免费友链[0元] 入坑免费教程学习源代码[0元] 网上百种+赚钱联盟推荐[?元]

↑↑VPS推荐网 WWW.VPS.COM.IN 稳定 便宜 免备案↑↑


您现在的位置是:首页 > 全球[VPS测评] >  wordpress技巧,WordPress教程,WordPress调用文章,便宜vps,VPS优惠,国外永久免费VPS

调用WordPress最新编辑/修改文章列表方法

全球[VPS测评]来源:VPS推荐网点击:679
【性价之王】【线路之王】【价格之王】【配置之王】
【免费之王】【香港首推】【梯子之王】【独服之王】
调用WordPress最新编辑/修改文章列表方法

我们在调整WordPress程序调用文章的时候,可能会有见过调用最新文章、热门文章,以及多少天热度文章的列表。但是,如果有一些文章是我们早期更新的,近期如果有变动重新编辑过的,这类的文章也是有需要重弄新作为编辑文章调用出来,这样可以告知用户这篇文章已经更新。

第一、调用脚本

// 最近修改和编辑的文章
function recently_updated_posts($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<$num ) : the_post();
if (current_time(\\’timestamp\\’) – get_the_time(\\’U\\’) > 60*60*24*$days) {
$i++;
$the_title_value=get_the_title();
$recently_updated_posts.=\\\'<li><i class=\\”icon-cai\\”></i><a h=\\”\\’.get_permalink().\\’\\” title=\\”最终修改于\\’.get_the_modified_time(\\’Y.m.d G:i\\’).\\’\\”>\\’
.$the_title_value.\\\'</a></li>\\’;
}
endwhile;
wp_reset_query();
if ( !empty($recently_updated_posts) ) update_option(\\’recently_updated_posts\\’, $recently_updated_posts);
}
$recently_updated_posts=($recently_updated_posts == \\’\\’) ? \\\'<li>请拭目以待.</li>\\’ : $recently_updated_posts;
echo $recently_updated_posts;
}
function clear_cache_zww() {
update_option(\\’recently_updated_posts\\’, \\’\\’);
}
add_action(\\’save_post\\’, \\’clear_cache_zww\\’);

将代码放到当前主题的Functions.php文件中。

第二、调用模块

<?php if ( function_exists(\\’recently_updated_posts\\’) ) recently_updated_posts(8,30); ?>

数字8表示调用八篇,30表示30天内修改编辑过的。数字可以根据实际调整。



猜你可能想看的VPS


转载请注明原文地址:http://140.238.13.167:12355/read-142140.html

下一篇       上一篇