最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Pagination not working on archive.php template?

programmeradmin1浏览0评论

I have an archive.php template which I only use for the blog.

The code goes a bit like this:

<?PHP
  $the_query = new WP_Query( array(
    'posts_per_page'=>9,
    'post_type'=>'blog',
    'paged' => get_query_var('paged') ? get_query_var('paged') : 1) 
   ); 
?>

<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

Title, text, etc pulled through

<?php endwhile; ?>

<?php
    $big = 999999999; // need an unlikely integer
    echo paginate_links( array(
        'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
        'format' => '?paged=%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $the_query->max_num_pages
    ) );
?>

<?php wp_reset_postdata(); ?>

But then I go to Page 2, my 404 page displays instead.

发布评论

评论列表(0)

  1. 暂无评论