在第二页上复制分页

时间:2014-12-13 作者:Nsokyi

我一直试图让它工作,我可以让它显示分页链接,但它只是重复了第二页第一页的内容,不知道为什么?

<div class="row">
    <div class="posts">
        <?php query_posts(\'showposts=10&paged=\' . get_query_var(\'paged\'));?>
        <?php $the_query = new WP_Query( \'showposts=12\' ); ?>
        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
        <?php get_template_part( \'partials/loop\', \'archive\' ); ?>
        <?php endwhile; ?>
        </div><!-- /posts -->
        </div><!-- /row -->
    </div>
    <!-- /large-10 -->
    <div class="large-2 show-for-large-up columns"></div>
    <div class="large-10 medium-12 small-12 columns">
        <?php if (function_exists(\'joints_page_navi\')) { ?>
        <?php joints_page_navi(); ?>
        <?php } else { ?>
        <nav class="wp-prev-next">
            <ul class="clearfix">
                <li class="prev-link"><?php next_posts_link(__(\'&laquo; Older Entries\', "jointstheme")) ?></li>
                <li class="next-link"><?php previous_posts_link(__(\'Newer Entries &raquo;\', "jointstheme")) ?></li>
            </ul>
        </nav>
        <?php } ?>
        </div>
    </div>
    <!-- /row -->

1 个回复
SO网友:Nsokyi

我发现this article 并让它发挥作用

    <div class="posts">
    <?php
    $paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
    $the_query = new WP_Query( \'cat=16&paged=\' . $paged );
    ?>
    <?php if ( $the_query->have_posts() ) : ?>
    <?php
    while ( $the_query->have_posts() ) : $the_query->the_post();
    ?>
    <?php get_template_part( \'partials/loop\', \'archive\' ); ?>
    <?php endwhile; ?>
    </div><!-- /posts -->
    </div><!-- /row -->
</div>
<!-- /large-10 -->
<div class="large-2 show-for-large-up columns"></div>
<div class="large-10 medium-12 small-12 columns">
    <?php
    next_posts_link( \'Older Entries\', $the_query->max_num_pages );
    previous_posts_link( \'Newer Entries\' );
    ?>
    </div><!-- /10 columns -->
    <?php
    wp_reset_postdata();
    ?>
    <?php else:  ?>
    <p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
    <?php endif; ?>
    <!-- /row -->
</section>
<!-- end Posts Section -->
上述方法可行,但如果我在页面navi插件的链接中出现,如:

<?php wp_pagenavi(); ?>
那么,如果我输入到上一页导航代码的链接,我会得到什么?

    <?php if (function_exists(\'joints_page_navi\')) { ?>
<?php joints_page_navi(); ?>
<?php } else { ?>
<nav class="wp-prev-next">
    <ul class="clearfix">
        <li class="prev-link"><?php next_posts_link(__(\'&laquo; Older Entries\', "jointstheme")) ?></li>
        <li class="next-link"><?php previous_posts_link(__(\'Newer Entries &raquo;\', "jointstheme")) ?></li>
    </ul>
</nav>
<?php } ?>

结束

相关推荐

Pagination and Related Posts

是否可以对嵌入在single中的以下相关POST代码使用分页。我的主题的php。 <?php // for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $