get_posts not returning all posts

前端 未结 2 721
北荒
北荒 2021-02-01 04:30

I have to mount the blog posts manually, but I\'m not sure if this is the correct way to work, It only brings 9 pages, with 4 posts each, but the blog has 83 posts!



        
相关标签:
2条回答
  • 2021-02-01 04:32

    The below note is from this codex section.

    Note: With use of the offset, the above query should be used only on a category that has more than one post in it, otherwise there'll be no output.

    So in-order to display all posts, there should be at-least 2 posts in each categories.

    You can try Loops to get all posts. Check The Loop in Action also.

    0 讨论(0)
  • 2021-02-01 04:38

    Problem is your 'numberposts' is set to 4 Put it at -1 to get all posts:

     'numberposts'       => -1,
    

    If you don't set numberposts here, WordPress will pull the number of posts from your Dashboard settings (under Settings -> Reading)

    0 讨论(0)
提交回复
热议问题