开发者

posts pagination in wordpress

开发者 https://www.devze.com 2023-01-23 16:02 出处:网络
i want to show 4 posts in page and after 4 posts it will show next button to read next posts. <?php while (have_posts()) : the_post(); ?>

i want to show 4 posts in page and after 4 posts it will show next button to read next posts.

        <?php while (have_posts()) : the_post(); ?>


<?php
            global $post;
            $myposts = get_posts('numberposts=4&order=ASC&category=3');
            foreach($myposts as $post) :
            setup_postdata($post);

            ?>

here is content with html

  开发者_C百科      <?php endforeach; ?>


        <?php endwhile; ?>

    <?php endif; ?>


You just need to add paged parameter to your query_posts:

$myposts = get_posts('numberposts=4&order=ASC&category=3&paged' . get_query_var('paged'));

And add post_nav_link() to display next and prev link.

<?php posts_nav_link(); ?>

Cheers, oh, btw, you can post specific wordpress question at wordpress.stackexchange.com.

0

精彩评论

暂无评论...
验证码 换一张
取 消