Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#45349 closed enhancement (reported-upstream)

Use WP_Query in render_block_core_latest_posts()

Reported by: sergey.r Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0
Component: Posts, Post Types Keywords:
Focuses: Cc:


Add a filter so that plugins and themes can filter the arguments.

Why is this needed:
Plugins may want to filter arguments in some situations. Eg. WPML will need to display posts in the current language only.

Attachments (1)

45349.patch (1.3 KB) - added by sergey.r 3 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Posts, Post Types
  • Keywords reporter-feedback added; has-patch removed
  • Severity changed from major to normal
  • Type changed from feature request to enhancement

Hi @sergey.r, welcome to WordPress Trac! Thanks for the ticket.

Eg. WPML will need to display posts in the current language only.

Wouldn't the existing pre_get_posts filter be sufficient for that? It runs on wp_get_recent_posts() as well.

#2 @gziolo
3 years ago

We have a more general solution proposed in https://github.com/WordPress/gutenberg/pull/11730 which should resolve this ticket.

#3 @swissspidy
3 years ago

@SergeyBiryukov wp_get_recent_posts() uses suppress_filters though

#4 @swissspidy
3 years ago

  • Milestone changed from Awaiting Review to 5.0.1
  • Summary changed from wp_get_recent_posts() Add filter for $args to Use WP_Query in render_block_core_latest_posts()

3 years ago

#5 @sergey.r
3 years ago

added a patch file, Thanks Guys for looking into this!

#6 @pento
3 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#7 @pento
3 years ago

  • Keywords reporter-feedback removed
  • Milestone 5.0.2 deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Thank you for the patch, @sergey.r! This file is maintained in the Gutenberg plugin, so will need to be handled in GB11984.

Note: See TracTickets for help on using tickets.