wordpress自定义页面输出所有文章列表
03 Apr 2013-
Copy 一份所用主题的 page.php,改名为 page-allpost.php
-
打开 page-allpost.php,找到类似下面这个文章内容输出函数
<?php the_content(); ?>
3.添加如下代码:
<div id="page-allpost">
<table>
<strong>All Post</strong>
<tr>
<td><strong>S.No</strong></td>
<td><strong>Published Date</strong></td>
<td><strong>Post Header</strong></td>
</tr>
<?php $count_posts = wp_count_posts(); $published_posts = $count_posts->publish;
query_posts( 'posts_per_page=-1' );
while ( have_posts() ) : the_post();
echo '<tr>';
echo '<td> </td>';
echo '<td> </td>';
echo '<td> </td>';
echo '</tr>';
echo '<tr>';
echo '<td width="100">'.$published_posts.'</td>';
echo '<td width="200">';
the_time(get_option( 'date_format' ));
echo '</td ><td><a href="';
the_permalink();
echo '" title="'.esc_attr( get_the_title() ).'">';
the_title();
echo '</a></td></tr>';
$published_posts--;
endwhile;
wp_reset_query(); ?>
</table>
</div>
4.新建一个页面,别名为 allpost