[英]Display archive posts in Wordpress
I am looking to display archives pages as a normal posts page... 我希望将存档页面显示为普通帖子页面...
So, a posts page with a secondary navigation showing: 因此,带有辅助导航的帖子页面显示:
LATEST POSTS / LAST MONTH / LAST YEAR / OLDER 最新文章/上个月/上一年/较旧
On each of those pages, I would like to display a summary of each post just like the standard latest news page. 在每个页面上,我都希望像标准的最新新闻页面一样显示每个帖子的摘要。 When you click through you get to the full post.
当您点击进入时,您会看到完整的帖子。
For each of menu items I have created seperate page templates such as archives_month.php
, Then in the template instead of using <?php wp_get_archives
I have been using <?php query_posts
and adding some time params but unfortunately I have no found the best / correct way to get these yet. 对于每个菜单项,我都创建了单独的页面模板,例如
archives_month.php
,然后在模板中,我不使用<?php wp_get_archives
而不是使用<?php query_posts
并添加了一些时间参数,但不幸的是,我没有找到最好的/正确的方式来获得这些。
I have one script that works: 我有一个可行的脚本:
<?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");?>
For the LAST MONTH page. 对于最后一个月页面。 But I now cannot use this for LAST YEAR and OLDER posts.
但是我现在不能在LAST YEAR和OLDER帖子中使用此功能。
Can anyone help me? 谁能帮我? I've looked into a number of different ways to do it but on some blogs it's not clear and most people just retrieve a list of archives rather than displaying the posts.
我研究了许多不同的方法来做,但是在一些博客上还不清楚,大多数人只是检索档案列表而不是显示帖子。
Thanks in advance. 提前致谢。 Mel
梅尔
You should be able to put something together using query_posts()
as described here . 你应该能够把东西一起使用
query_posts()
所描述的在这里 。
An example from the linked page for building a query fetching all posts in March 2009: 来自链接页面的示例,该示例用于构建查询以获取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);
?>
you will find it easy to adjust. 您会发现它很容易调整。
The output can then be done using The Loop: 然后可以使用The Loop完成输出:
// the Loop
while (have_posts()) : the_post();
// the content of the post
the_content('Read the full post »');
endwhile;
For more info on how to customize the stuff displayed in The Loop (to show the summary you talk about) see here . 有关如何自定义The Loop中显示的内容的更多信息(以显示您所讨论的摘要),请参见此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.