Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Sticky Posts and Most Recent Posts

  • I have two query loops on same page.

    I need first query loop to show only one post. The sorted post should be the most recent sticky post OR, in case there are no sticky posts, the most recent post should be shown.

    I need the second query loop to show 4 posts (offset 1). The sorted posts should be the most recent sticky posts OR, in case there are no sticky posts or even if there are less than 4 sticky posts, the most recent posts should be shown (always considering offset 1 in this second query loop).

    I´ve tried all combinations of settings using the “sticky” parameters and the “post per page” parameters and none of them worked as I need.

    If I choose the “include” option in “Sticky posts” and choose “1” in “posts per page”, the query loop presents all the sticky posts and, at the end of this list, presents 1 unstickypost.

    If I choose the “only” option in “Sticky posts” and choose “1” in “posts per page”, the query loop presents only one sticky post (OK), but if there are no sticky posts, the query does not present the unsticky posts, leaving an empty space on the page.

    Please, Is there any way I can get the query results I need?

  • Hi there,

    Offset and posts per page do not work with sticky posts, WP simply adds the sticky posts before the 1st post of query loops if no specific settings are set for sticky posts.

    I would recommend using a specific tag or category for those posts instead of using the sticky feature, but you need to make sure there’re 5 or more posts in that specific tag/category.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.