[英]Display archive posts in Wordpress
我希望将存档页面显示为普通帖子页面...
因此,带有辅助导航的帖子页面显示:
最新文章/上个月/上一年/较旧
在每个页面上,我都希望像标准的最新新闻页面一样显示每个帖子的摘要。 当您点击进入时,您会看到完整的帖子。
对于每个菜单项,我都创建了单独的页面模板,例如archives_month.php
,然后在模板中,我不使用<?php wp_get_archives
而不是使用<?php query_posts
并添加了一些时间参数,但不幸的是,我没有找到最好的/正确的方式来获得这些。
我有一个可行的脚本:
<?php if (have_posts()) : ?>
<?php $current_month = date('m');?>
<?php $current_year = date('Y');?>
<?php $current_year = $current_year - 24;?>
<?php query_posts("cat=5&year=$current_year&monthnum=$current_month");?>
对于最后一个月页面。 但是我现在不能在LAST YEAR和OLDER帖子中使用此功能。
谁能帮我? 我研究了许多不同的方法来做,但是在一些博客上还不清楚,大多数人只是检索档案列表而不是显示帖子。
提前致谢。 梅尔
你应该能够把东西一起使用query_posts()
所描述的在这里 。
来自链接页面的示例,该示例用于构建查询以获取2009年3月的所有帖子:
<?php
//based on Austin Matzko's code from wp-hackers email list
function filter_where($where = '') {
//posts for March 1 to March 15, 2009
$where .= " AND post_date >= '2009-03-01' AND post_date < '2009-03-16'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
您会发现它很容易调整。
然后可以使用The Loop完成输出:
// the Loop
while (have_posts()) : the_post();
// the content of the post
the_content('Read the full post »');
endwhile;
有关如何自定义The Loop中显示的内容的更多信息(以显示您所讨论的摘要),请参见此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.