[wp-trac] [WordPress Trac] #37578: Dashboard Recent Activity widget - new filters to manipulate output
WordPress Trac
noreply at wordpress.org
Fri May 30 09:51:16 UTC 2025
#37578: Dashboard Recent Activity widget - new filters to manipulate output
-------------------------------------------------+-------------------------
Reporter: Jonnyauk | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Administration | Version: 4.6
Severity: normal | Resolution:
Keywords: has-patch good-first-bug needs- | Focuses:
test-info |
-------------------------------------------------+-------------------------
Comment (by pmbaldha):
@SirLouen
**Usecases:**
1. If you want to show 10 posts instead of the default 5:
{{{
add_filter( 'dashboard_recent_posts_query_args',
'increase_dashboard_post_count', 10, 2 );
function increase_dashboard_post_count( $args, $id ) {
$args['max'] = 10;
return $args;
}
}}}
2. Show Only Posts from a Specific Category in "Recently Published"
If your site has multiple categories and you want the widget to only show
posts from the "Announcements" category:
{{{
add_filter( 'dashboard_recent_posts_query_args',
'dashboard_recent_posts_announcements_only', 10, 2 );
function dashboard_recent_posts_announcements_only( $args, $id ) {
if ( 'published-posts' === $id ) {
$args['cat'] = get_cat_ID( 'Announcements' );
}
return $args;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37578#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list