造型wordpress帖子循环

时间:2015-07-07 08:39:46

标签: php wordpress loops

我一直在尝试编辑wordpress博客页面的代码。我有14个帖子,我已将页面设置为每页显示5个帖子。但是,它不起作用。前5个帖子显示得很好,但是当你点击"较旧的条目"时,什么都没有。我试图让它每页显示5个帖子。这是代码:

<div id="blog_content_row">

    <div class="container">

        <div class="row">

            <div class="article editable">

                <div>

                    <?php



                    // Title on some archive views

                    get_template_part( 'parts/title', 'archive');



                    // display featured sometimes

                    if (!is_paged() && is_home()) {

                        $original_query = $wp_query;

                        $wp_query = null;

                        $wp_query = new WP_Query(array('posts_per_page' => 5, 'meta_key' => 'featured_post', 'meta_value' => 'true', 'post__not_in' => get_option( 'sticky_posts' )));

                        if ($wp_query->have_posts()) {

                        } else {

                            $wp_query = null;

                            $wp_query = new WP_Query(array('posts_per_page' => 5, 'post__not_in' => get_option( 'sticky_posts' )));

                        }

                        if (have_posts()) {

                            while (have_posts()) {

                                the_post();

                                $nimbus_feature_id = $post->ID;

                                get_template_part( 'parts/blog', 'featured');

                            }

                        } else {

                            // get_template_part( 'parts/error', 'no_results');

                        }

                        get_template_part( 'parts/blog', 'pagination');

                        $wp_query = null;

                        $wp_query = $original_query;

                        wp_reset_postdata();

                    }



                    // display author stuff here

                    if (is_author()) {

                        get_template_part( 'parts/bio');

                    }


                    ?>

                </div>

            </div>



        </div>

    </div>

</div>
你能告诉我什么是错的吗?我认为这可能与$ wp_query有关。有问题的网页是http://disa.com.sv/constructora/?page_id=10

1 个答案:

答案 0 :(得分:0)

找到答案。它不在代码中。代码很好。最重要的是functions.php。

https://wordpress.stackexchange.com/questions/181487/archive-page-limiting-posts-per-page

我编辑了它,现在就可以了。

然而问题是它一直显示相同的5个帖子而不是14个不同的帖子。帮助