WP查询帖子分页不起作用

时间:2015-03-25 12:24:38

标签: php wordpress pagination

在我的WP模板index.php文件中添加query_posts代码之后,我的分页不再有效了。我确实使用了搜索并尝试了一些方法,但似乎没有什么对我有用。

我所做的只是将行<?php if ( is_home() ) {query_posts( 'cat=-85' );}?>添加到此代码中:

<?php get_header(); ?>
    <div id="primary" class="content-area clr">
        <div id="content" class="site-content" role="main">
            <div class="container clr">
                <div id="post" class="col col-1 span_3_of_4 clr">

                    <?php if ( is_home() ) {query_posts( 'cat=-85' );}?>
                    <?php while ( have_posts() ) : the_post(); ?>
                        <?php get_template_part( 'content', get_post_format() ); ?>
                    <?php endwhile; ?>
                    <?php wpex_pagination(); ?>
                </div><!-- #post -->     
                <?php get_sidebar(); ?>
            </div><!-- #post -->
        </div><!-- #content -->
    </div><!-- #primary -->
<?php get_footer(); ?>

你能帮助我吗?

1 个答案:

答案 0 :(得分:-1)

我找到了解决方案:

<?php if ( is_home() ) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string . '&cat=-85&paged='.$paged);
} ?>
相关问题