Skip to content

Instantly share code, notes, and snippets.

@douglasanro
Created April 22, 2017 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglasanro/2f41b0a198f4822508c4a1694c4e3bf1 to your computer and use it in GitHub Desktop.
Save douglasanro/2f41b0a198f4822508c4a1694c4e3bf1 to your computer and use it in GitHub Desktop.
Add the support for your WordPress CPT in the widget activity of the admin dashboard
<?php
/* ----------------------------------------------------------------------------
* Add the support for your CPT in the widget activity of the admin dashboard
* ------------------------------------------------------------------------- */
add_filter( 'dashboard_recent_posts_query_args', 'add_page_to_dashboard_activity' );
function add_page_to_dashboard_activity( $query_args ) {
// Return all post types
$query_args['post_type'] = 'any';
// Or return post types of your choice
// query_args['post_type'] = array( 'post', 'foo', 'bar' );
if ( $query_args['post_status'] == 'publish' ) {
$query_args['posts_per_page'] = 10;
}
return $query_args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment