previous_posts_link无法在WordPress分页中使用

时间:2015-05-12 12:44:03

标签: php wordpress wp-query

当我点击较旧的条目(next_posts_link)时,它工作正常&转到下一页。但是我没有看到更新的条目(previous_posts_link),所以我可以再次回到第一页或上一页。我使用自定义查询在主页上显示我的一些帖子。这是我的片段:

            <ul class="recipe-list">
                <?php
                    $home_rcp= $redux_imd['home_rcp'];

                    // Define custom query parameters
                    $rcpquery_args = array(
                    'cat' => $home_rcp,
                    'posts_per_page' => 4
                    );

                    // Get current page and append to custom query parameters array
                    $rcpquery_args['paged'] = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;

                    // Instantiate custom query
                    $rcpquery =  new WP_Query( $rcpquery_args );

                    // Pagination fix
                    $temp_query = $wp_query;
                    $wp_query   = NULL;
                    $wp_query   = $rcpquery;

                    while($rcpquery->have_posts()) : $rcpquery->the_post();
                ?>
                <li>
                    <?php the_post_thumbnail('recipe-thumb'); ?>
                    <div class="caption">
                        <div class="blur"></div>
                        <div class="caption-text">
                            <div class="post-title">
                                <h5><?php the_title() ?></h5>
                            </div>
                            <div class="recipe-home-meta">
                                <p>Posted  on <?php the_time('Y/m/d'); ?> By <?php the_author(); ?></p>
                            </div>
                            <a href="<?php the_permalink() ?>" rel="bookmark">SEE THIS RECIPE</a>
                        </div>
                    </div>
                </li>
                <?php endwhile; 
                wp_reset_postdata();
                ?>
                <div id="pagination">
                <?php next_posts_link('&laquo; Older Entries', $rcpquery->max_num_pages); ?>
                <?php previous_posts_link('Newer Entries &raquo;', $rcpquery->max_num_pages); ?>
                </div>
                <?php 
                // Reset main query object
                $wp_query = NULL;
                $wp_query = $temp_query;
                ?>
            </ul> 

0 个答案:

没有答案