功能介绍:不想在首页/列表页显示最新的文章,需要显示指定时间内的文章。
解决方法如下:
在query_posts($query_string);上面显示以下代码:
只显示<=前天发布的文章
if ( have_posts() ) {
function filter_where($where = '') {
$where .= " AND post_date <= '" . date('Y-m-d', strtotime('-1 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
...
...
}
显示30天内发布的文章
if ( have_posts() ) {
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
...
...
}
只显示过去30天-60天内发布的文章
if ( have_posts() ) {
function filter_where($where = '') {
$where .= " AND post_date >= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
...
...
}
只显示某个时间段内发布的文章
if ( have_posts() ) {
function filter_where($where = '') {
$where .= " AND post_date >= '2022-03-01' AND post_date < '2023-03-01'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
...
...
}
上面是“wordpress首页(列表页)如何显示指定时间内的文章”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3461.html
workflows工作流
一个戴着破旧莎草帽的机械忍者
一张精心制作的熊岛复古地图ComfyUI工作流
一个闪闪发光的金属球ComfyUI工作流
荷塘月色ComfyUI工作流
一只穿着黑色蝴蝶结西装可爱橙色小猫
一个十几岁的美国女孩穿着黄色连帽衫在黑暗和空虚的背景下闲逛
一张皮卡丘向观众眨眼的逼真照片ComfyUI工作流
一只蚊子被嵌在琥珀中ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

会议人员60s签到倒计时插件
Bootstrap可视化拖放布局
SVG路径动画效果
css3卡片动态滑动效果
一起去看流星雨(代码)
iframe开发admin后台
在线生成金属文字
纯html+css做一个3d统计效果










