paged query leads to 404?

时间:2014-01-14 作者:mathiregister

当我点击分页链接上的“2”时,我得到一个404错误。url正确更改为http://mysite.com/?paged=2

<?php
/**
 * The loop that displays the posts.
 */
?>


<ul class="post-items">
<?php

    $args = array(
        \'post_type\' => array(\'post\', \'wr_raffle\'),
        \'posts_per_page\' => 4,
        \'order\' => \'DESC\',
        \'paged\' => (get_query_var(\'page\')) ? get_query_var(\'page\') : 1,
    );

    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); ?>

        <li>
        <article id="post-<?php the_ID(); ?>" <?php post_class(\'wrapper\'); ?>>

            <div class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
            <div class="post-excerpt text small"><?php the_excerpt(); ?></div>

        </article>
        </li>

        <?php endif; ?>

    <?php 
    endwhile;
    wp_reset_postdata();

?>      
</ul>

<div class="pagination wrapper clear">
<?php
    $endsize = $midsize = 1;
    $type = \'plain\';
    $loop->query_vars[\'paged\'] > 1 ? $current = $loop->query_vars[\'paged\'] : $current = 1;

    // Sanitize input argument values
    if ( ! in_array( $type, array( \'plain\', \'list\', \'array\' ) ) ) $type = \'plain\';
    $endsize = (int) $endsize;
    $midsize = (int) $midsize;

    // Setup argument array for paginate_links()
    $pagination = array(
        //\'base\'          => @add_query_arg(\'paged\',\'%#%\'),
        \'total\'         => $loop->max_num_pages,
        \'current\'       => $current,
        \'show_all\'      => false,
        \'end_size\'      => $endsize,
        \'mid_size\'      => $midsize,
        \'type\'          => $type,
        \'prev_next\'     => false,
        //\'paged\'         => $loop->query_vars[\'paged\']
    );

    echo paginate_links( $pagination );
?>
 </div>
我做错了什么?

我已经刷新了永久链接。不起作用。

0 个回复
结束

相关推荐

Blog only showing code

我想得到一些帮助。我在运行apache2的raspberry pi中主持了一个wordpress博客,但当我浏览博客时,它只显示您在这里看到的代码http://lifeonpi.sytes.net/raspgrammer/我能做什么?它有什么问题?有什么帮助吗?