Make WordPress Core

Opened 2 months ago

Last modified 4 weeks ago

#62975 new defect (bug)

Twenty Twenty-Five: Exclude sticky posts when offset is used

Reported by: poena's profile poena Owned by:
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords:
Focuses: Cc:

Description (last modified by poena)

In Twenty Twenty-Five, there are several templates that use query loop blocks with offsets.

Sticky posts are not hidden by default when offset is used, which means that if a website has sticky posts, they show more than once when the templates are used.

The repeated content is not desired because it is not a good experience for visitors.

See this support request:
https://wordpress.org/support/topic/posts-loop-broken-when-complex-blog-template-used/

This can be solved by updating the query loops that have offsets to also ignore sticky posts.
The "ignore" option is planned to be added in WordPress 6.8. See https://core.trac.wordpress.org/ticket/62908

Another alternative would be to use "exclude" sticky posts, then the sticky would not be repeated, but it would not be shown at all.


Users can also remove the sticky status from their posts. But it is not so easy for users to discover that they can solve the problem that way.

Change History (9)

#1 @poena
2 months ago

  • Description modified (diff)

#2 @poena
2 months ago

Update: Actually the ignore can't be used because it would cause a block validation error on versions below 6.8. Sigh.

#3 @abcd95
2 months ago

Hi @poena, Thanks for bringing this to Trac!

I have been thinking about this and maybe we can completely remove sticky posts from offset queries, or add a custom filter to dynamically exclude sticky posts only when offset is used.

The former approach is simpler but more restrictive, while the latter offers more flexibility. What are your thoughts on this?

#4 follow-up: @poena
2 months ago

Did you mean that the change should be made in the query loop block itself and not in the theme?

I think the expectation is that the behaviour of the query loop should match wp query, where the sticky posts are not removed by the offset.

#5 in reply to: ↑ 4 @abcd95
2 months ago

Replying to poena:

Did you mean that the change should be made in the query loop block itself and not in the theme?

Actually, that makes more sense. Perhaps we could restructure affected templates to either split the query (sticky posts + offset posts) or provide alternative templates without offsets?

#6 @rinkalpagdar
2 months ago

@poena Can you please provide testing instructions if possible? Thanks!

#7 @poena
2 months ago

The testing instruction are:
Create a few sticky posts.
Go to Appearance > Editor > Templates
Open a template that uses query loops and has design alternatives.
Select a design that has multiple loops.
Save. View the template on the front of the site.

#8 @rinkalpagdar
2 months ago

Hello @poena Thanks for the quick repose. I can reproduce the issue. Also, I have tested it with various themes and learned that it's not an issue with the query loop block but with the theme template. Am I right? Please correct me if I am wrong

#9 @poena
4 weeks ago

  • Milestone changed from Awaiting Review to 6.9

Yes the issue is in the theme templates / patterns. The designs with multiple query loop needs have sticky set to exclude.

Note: See TracTickets for help on using tickets.