Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wassim/edff111575fad9085a92ebea68988fbd to your computer and use it in GitHub Desktop.
Save wassim/edff111575fad9085a92ebea68988fbd to your computer and use it in GitHub Desktop.
Add custom post types to "Activity" widget in WordPress Dashboard.
add_filter( 'dashboard_recent_posts_query_args', function ( $query_args ) {
  // Return public built-in posts + custom post types with 'post' capabilities
  $post_types = get_post_types( array( 'public' => true, "capability_type" => "post" ) );
  if ( is_array( $query_args['post_type'] ) ) {
    $query_args['post_type'] = $post_types;
  } else {
    $temp = $post_types;
    $query_args['post_type'] = $temp;
  }
  return $query_args;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment