分享我的文章列表页源代码。将下面代码上传到你使用的主题风格文件夹中。

进入博客管理后台,新建页面——右面模板选择Posts——写上页面标题——发布。

\<?php /\* Template Name: Posts \*/ ?\> \<?php get\_header(); ?\> \<div id="content-body"\> \<?php if ( function\_exists('yoast\_breadcrumb') ) { yoast\_breadcrumb('\<p id="breadcrumbs"\>','\</p\>'); } ?\> \<?php if (have\_posts()) : while (have\_posts()) : the\_post(); ?\> \<div \<?php if (function\_exists("post\_class")) post\_class(); else print 'class="post"'; ?\> id="post-\<?php the\_ID(); ?\>"\> \<h2\>\<a title="\<?php the\_title(); ?\>" href="\<?php the\_permalink() ?\>" rel="bookmark"\>\<?php the\_title(); ?\>\</a\>\</h2\> \<?php edit\_post\_link(\_\_('Edit this page','lightword'), '', ''); ?\> \<?php $previous\_year = $year = 0; $previous\_month = $month = 0; $ul\_open = false; $myposts = get\_posts('numberposts=-1&orderby=post\_date&order=DESC'); ?\> \<?php foreach($myposts as $post) : ?\> \<?php setup\_postdata($post); $year = mysql2date('Y', $post-\>post\_date); $month = mysql2date('n', $post-\>post\_date); $day = mysql2date('j', $post-\>post\_date); ?\> \<?php if($year != $previous\_year || $month != $previous\_month) : ?\> \<?php if($ul\_open == true) : ?\> \</ul\> \<?php endif; ?\> \<h3\>\<?php the\_time('Y年 F'); ?\>\</h3\> \<ul\> \<?php $ul\_open = true; ?\> \<?php endif; ?\> \<?php $previous\_year = $year; $previous\_month = $month; ?\> \<li\>\<span\>\<?php the\_time('Y/m/d'); ?\>\</span\> \<span\>\<a href="\<?php the\_permalink(); ?\>"\>\<?php the\_title(); ?\>\</a\>\</span\> \<span\>&nbsp;\<?php if(function\_exists('the\_views')) { the\_views(); } ?\>\</span\> \<?php comments\_popup\_link( \_\_( '评论 (0)', 'farlee' ), \_\_( '评论 (1)', 'farlee' ), \_\_( '评论 (%)', 'farlee' ), 'comments-link', \_\_('评论关闭', 'farlee')); ?\> \</li\> \<?php endforeach; ?\> \</ul\> \<?php if(function\_exists('wp\_print')) { print\_link(); } ?\> \<?php wp\_link\_pages('before=\<div class="nav\_link"\>'.\_\_('PAGES','lightword').': &after=\</div\>&next\_or\_number=number&pagelink=\<span class="page\_number"\>%\</span\>'); ?\> \</div\> \<?php if ( comments\_open() && $lw\_disable\_comments == "false" ) : comments\_template(); endif; ?\> \<?php endwhile; else: ?\> \<h2\>\<?php \_e('Not Found','lightword'); ?\>\</h2\> \<p\>\<?php \_e("Sorry, but you are looking for something that isn't here.","lightword"); ?\>\</p\> \<?php endif; ?\> \</div\> \<?php get\_sidebar(); ?\> \<?php get\_footer(); ?\>