【发布时间】:2015-09-18 21:03:05
【问题描述】:
我需要为大约 30.000 个帖子建立一个存档页面。我尝试使用 wordpress 的标准存档方法,但它并没有完全涵盖我想要做的事情。
这是我目前所拥有的:
<?php
/*
Template Name: Archives
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php
// Get total number of posts for pagination
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
$args = array(
'post_type' => 'post',
'posts_per_page' => 50
);
$post_query = new WP_Query($args);
?>
<table style="width:100%">
<tr>
<th>Post</th>
<th>Datum</th>
<th>Categorie</th>
</tr>
<?php
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
echo "<tr>";
$post_query->the_post();
?>
<td><a href="<?php the_permalink() ?>" rel="bookmark" title="Link naar <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
echo "<td>" . get_the_date() . "</td>";
$category_list = get_the_category_list( ', ' );
if ( $category_list )
echo "<td>" . $category_list . "</td>";
echo "</tr>";
}
}
echo "</table>";
?>
</div><!-- #content -->
现在我将所有帖子都放在一个页面上,这并不容易使用。因此,我需要进行分页以提供更多概述。我知道这一定是可能的,但我真的不知道该怎么做。
真的希望将来有人可以帮助我和某些人。也许还有另一种我找不到的解决方案。
【问题讨论】:
标签: php jquery wordpress pagination