0

我想在我的首页最后一篇文章中添加分页,但我一直失败..!我的代码:

                    <?php
                        $recentPosts = new WP_Query();
                        $recentPosts->query('showposts=4&cat=3');
                    ?>
                <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
                    <div id="thepost">
                        <div class="view view-fifth">
                            <?php if ( has_post_thumbnail()) : the_post_thumbnail('thumbnail'); endif; ?>
                        <div class="mask">
                            <h2>title</h2>
                            <p><?php echo get_the_date(); ?></p>
                        </div>
                    </div>
                    <p class="posttitle"><a class="ajax" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>"><?php the_title(); ?></a></p>
                    <hr class="hr"/>
                    <p class="postcontent"><?php echo substr(strip_tags($post->post_content), 42, 120);?>...&nbsp;<a class="ajax" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">more...</a></p>
                    </div>
                <?php endwhile; ?>

我有 ajaxify 我的“更多...”按钮,所以我想为分页做同样的事情:) 对不起我的英语不好...

4

1 回答 1

1

您需要使用query_postsinsted of Wp_Query

有时分页不起作用Wp_Query

试试这个:1)http://codex.wordpress.org/Function_Reference/query_posts 2)http://codex.wordpress.org/Function_Reference/paginate_links

于 2013-09-27T09:35:28.743 回答