Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#31085 new enhancement

CPT selector to “Recent Posts” widget

Reported by: sippis's profile sippis Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: Widgets Keywords: has-patch 2nd-opinion needs-refresh
Focuses: Cc:


I think that "Recent Posts" widget should support selection to show all posts or only in selected CPT.

Attachments (1)

31085.diff (3.8 KB) - added by sippis 9 years ago.

Download all attachments as: .zip

Change History (5)

9 years ago

#1 @sippis
9 years ago

  • Keywords has-patch 2nd-opinion added

My first patch, be nice :p

Selector is displayed only if there is post types that are not built in and those are public, it defaults to 'post' and also allows to choose that or 'any' alongside CPT's.

Patch contains two new filters;

  • widget_posts_cpt_args to change arguments passed for get_post_types
  • widget_posts_cpt_selector if false, selector will not be displayed

Yes, most of users probably will not need this functionality and will get confused when they see it. However, as a developer, it's annoying to invent the wheel again every single time and make own widget for this functionality when there is already good basic widget for recent posts.

This ticket was mentioned in Slack in #core by sippis. View the logs.

9 years ago

#3 @jipmoors
9 years ago

I would suggest to use 'post_type' instead of 'cpt' for the argument.

Next to that, what if I wanted to display two types of post-types instead of just one?
If you want to extend this functionality, I recommend to make it a bit broader (multi-select and array for options).

#4 @swissspidy
9 years ago

  • Keywords needs-refresh added

Patch would need a refresh to be considered. I'm just not sure if this is really needed by that many people.

Custom post types are usually very specific, like products or portfolio items. You don't really want to list those together with blog posts.

Note: See TracTickets for help on using tickets.