Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#43174 closed defect (bug) (invalid)

Gutenberg uses deprecated recent posts

Reported by: lewiscowles's profile LewisCowles Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Posts, Post Types Keywords:
Focuses: ui, administration Cc:


Looking to use some work from latest posts widget in Gutenberg. It seems that it's pulling from a deprecated function which branches from the normal side-bar widget version (called recent posts, but recent / latest are mostly synonymous).

There is no filter for args (or anything else) in either the gutenberg decorator nor the wp_get_recent_posts method. I think this hints at inconsistency that could be problematic for new users.

It's been problematic for me when testing more control via tags in featured / curated content using post tags. seems quite concise and seems to be able to drop-in fix the wp_get_recent_posts method with a change to the filter and WP_Query directly instead of via get_posts.

Happy to take up fixing.

Change History (7)

#1 @swissspidy
6 years ago

  • Component changed from General to Posts, Post Types

So what exactly should be fixed? If you want Gutenberg to use WP_Query for that block, you should open an issue on GitHub.

Note: wp_get_recent_posts() isn't deprecated. It's just not used in core except for the XML-RPC API.

#2 @LewisCowles
6 years ago

Hi @swissspidy,

Gutenberg already indirectly uses WP_Query that's how get_posts works. The issue is that there is no way to hook what is sent to WP_Query in either the gutenberg widget (which has a confusing name, hence ui tag), or get_posts.

I am looking into WP_Query but Imagine it will have the same result or lack of control (I only want to curate recent/latest posts).

Thanks for letting me know about Gutenberg. I will be raising an issue on the GitHub, but it looks like any change would likely need to be in core also (as it's simply using core, and the functionality I'd like is buried within a widget class).

I can understand why things are the way they are. But I also believe I can make them better without changing the main or edge cases, or making yet another take on recent posts...

Last edited 6 years ago by LewisCowles (previous) (diff)

#4 @peterwilsoncc
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

@LewisCowles Thanks for opening the issue on Gutenberg's GitHub issue tracker. I'm closing this ticket off now it's being tracked elsewhere.

#5 @LewisCowles
6 years ago

What happens if they accept the issue? It's not just a Gutenberg fix, it requires changes to core, or duplicate code...

#6 @swissspidy
6 years ago

Gutenberg switching to a custom WP_Query with the same filter as the Recent Posts widget doesn‘t require any change in core.

#7 @LewisCowles
6 years ago

You must understand that means it'll be broken for Gutenberg forever then?

Is it a planned degradation of recent post functionality?

I'd just like to understand what the logic is.

Right now Gutenberg pulls from WP core. It pulls from a method that cannot be hooked into.

If it switches to a WP_Query it seems to make sense to have it pull from recent posts, since recent and latest post do pretty much the same thing.

I'm finding it hard to understand why that wouldn't benefit core from moving that recent posts functionality into posts (because there is a similar function that does the same thing), and just having one place instead of three for themes, plugins and maintenance.

Less posts to maintain, existing code is completely covered (no new tests, if anything perhaps being able to remove tests, and code).

Last edited 6 years ago by LewisCowles (previous) (diff)
Note: See TracTickets for help on using tickets.