-
最近发现好多博友开始把自己的博客迁移到了 WordPress 构架上,同时也不少同学发帖求助希望能够增加存档页面,也就是站点所有文章的集合。
下面介绍一种陈德馨博客使用的存档方式,先看代码:
<div class="archives"> <?php $previous_year = $year = 0; $previous_month = $month = 0; $ul_open = false; $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC'); foreach($myposts as $post) : setup_postdata($post); $year = mysql2date('Y', $post->post_date); $month = mysql2date('n', $post->post_date); $day = mysql2date('j', $post->post_date); if($year != $previous_year || $month != $previous_month) : if($ul_open == true) : echo '</table>'; endif; echo '<h3>'; echo the_time('F Y'); echo '</h3>'; echo '<table>'; $ul_open = true; endif; $previous_year = $year; $previous_month = $month; ?> <tr> <td width="40" style="text-align:right;"><?php the_time('j'); ?>日</td> <td width="400"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td> <td width="120"><a class="comm" href="<?php comments_link(); ?>" title="查看 <?php the_title(); ?> 的评论"><?php comments_number('0', '1', '%'); ?>人评论</a></td> <td width="120"><span class="view"><?php if(function_exists('the_views')) the_views(); ?>次浏览</span></td> </tr> <?php endforeach; ?> </table> </div>
复制以上代码到你希望显示的页面,或者自行后台-页面-新建页面。
显示样式:
<style type="text/css"> .archives td{padding: 6px 10px 8px;border-bottom: solid 1px #eee} .archives table{padding:10px 0 20px} .meta-tit{border-bottom: solid 1px #e6e6e6;padding: 0 0 10px;margin-bottom: 20px} </style>
如不喜欢以上样式可以自行修改。
其实Wordpress存档页面就是这么简单,如果你安装了wp-postviews插件,存档页面中将显示文章浏览次数,很不错吧!
WordPress 存档页面模板制作方法
2046人参与 |分类: 站长百科|时间: 2013年07月21日
相关文章
- 2020-05-09WordPress使用timthumb.php截取文章缩略图
- 2018-11-09一键安装KMS服务脚本 搭建自己的KMS激活服务器教程
- 2018-10-30Windows 10系统的3D Objects(3D对象)文件夹如何删除
- 2018-03-16WINGHO..文件夹删除方法
- 2017-12-23WordPress博客什么时候才需要使用缓存插件?
- 2017-12-05WordPress站点SEO优化中需要避开6个常见错误
- 2017-11-11升级WordPress时提示’另一更新正在进行’的解决方法
- 2017-11-02WordPress上传文件自动重命名
- 2017-10-28WordPress前台显示用户的注册时间
- 2017-08-15WordPress发布/更新文章、提交/审核评论自动清理阿里云CDN缓存