WordPress.org

Ready to get started?Download WordPress

Forums

Strange sticky posts and posts per page calculation (7 posts)

  1. felixhirschfeld
    Member
    Posted 1 year ago #

    Hey there,

    i discovered a strange behavior with sticky posts in wordpress.

    when i have sticky posts, they're added to the max posts per page, right? but when i have more than 3 it looks like there not added anymore. all other sticky posts are taken off from he max posts per page.

    For example:

    I set 12 posts per page and i have 3 sticky posts. now it displays 15 posts on the first page of the blog. now when i add another sticky post, there are still 15 posts displayed, but now 4 sticky and 8 normal posts.

    or:

    9 stickys, 12 posts per page, 16 posts displayed.

    or:

    9 stickys, 20 posts per page, 22 posts displayed.

    I really don't understand how it's been calculated. this makes no sense at all.

    Does anyone have problems with this too?

    thx,
    felix

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Can you replicate this using the default 2012 theme with all plugins deactivated?

  3. felixhirschfeld
    Member
    Posted 1 year ago #

    i disabled all plugins and using the deafult 2012 theme.

    i tested this:

    3 stickys, 12 posts per page, 15 displayed

    4 stickys, 12 posts per page, 15 displayed

    3 stickys, 20 posts per page, 21 displayed

    9 stickys, 12 posts per page, 15 displayed

    9 stickys, 20 posts per page, 21 displayed

    i really don't understand this

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    I think it depends upon whether any of the stickies would normally be on the front page anyway. If they were on the front page, they're only shown as sticky and not in the normal date order. If they would have been on page 2, then they are stickied and shown on page 2. All of this can affect the number of posts being displayed on page 1.

    Does that make some kind of sense?

  5. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    I'm going to take a stab, and guess that the difference is whether the sticky posts are on the first page, or subsequent pages, in the current pagination.

    Of the 3 sticky posts, 2 are on page 2, and one on page 3, with 12 posts per page?
    Of the 4 sticky posts, 1 is on page 1, 2 are on page 2, and 1 is on page 3, with 12 posts per page?

    Of the 9 sticky posts, 3 are on page 1, and 6 are on subsequent pages, with 12 posts per page?
    Of the 9 sticky posts, 8 are on page 1, and 1 is on a subsequent page, with 20 posts per page?

    I believe that WordPress pulls sticky posts out of the normal post flow, including posts per page/pagination. If the sticky posts would normally fall on the first page with the current pagination, then the number of posts displayed on the first page will be unaffected. But, if the sticky posts would normally fall past the first page with the current pagination, the first page will display more posts than the posts_per_page setting.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Cool! That's exactly my understanding of the situation too - only your explanation was much better than mine. :-)

  7. felixhirschfeld
    Member
    Posted 1 year ago #

    OK now it all makes sense :)

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic