Wordpress - 通过基于类别的年度存档进行分页

时间:2016-08-09 16:23:30

标签: php wordpress pagination

我试图通过基于特定类别的年度存档进行分页,即:​​

本地主机:8080 /类别/新闻稿/ 2016 /

该网址显示与年份相关的所有新闻稿:

<a href="/category/press-releases/2010">2010</a>
<a href="/category/press-releases/2011/">2011</a>
<a href="/category/press-releases/2012">2012</a>
<a href="/category/press-releases/2013">2013</a>
<a href="/category/press-releases/2014">2014</a>
<a href="/category/press-releases/2015">2015</a>
<a href="/category/press-releases/2016">2016</a>

看着我的代码:

<?php 
$query = $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' group by postyear", $wpdb->siteid );
?>
    <?php $oldyear = $postyear = get_the_time('Y', $post->ID);?>
    <h4><?php echo $postyear; ?></h4>
    <ul class="archive-posts"><?php
    while (have_posts()) {
        the_post();
        $postyear = get_the_time('Y', $post->ID);
        if ($oldyear != $postyear) {
            $oldyear = $postyear; ?>
            </ul><h4><?php echo $postyear; ?></h4><ul class="archive-posts">
            <?php
    } ?>
    <li><span class="archive-post-title">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
    </a></span><span class="archive-post-date"><?php the_time(get_option('date_format')); ?></span></li><?php
}
echo '</ul>';
?>

一切正常,并显示与特定年份相关的所有帖子。理想情况下,我想要做的是每页显示5个帖子,并在那一年中通过其余部分分页。我一直在处理许多循环,各种函数,重写,固定链接更改,但每当我点击url:/ category / press-releases / 2016 / page / 2时 - 结果总是404.

如果有人能指出我正确的方向如何实现这一目标,我将非常感激,因为我有点沮丧。

欢呼你阅读, 〜chipleh

0 个答案:

没有答案