[wp-trac] [WordPress Trac] #29374: Add hook(s) to include other post types in the Activity widget

WordPress Trac noreply at wordpress.org
Wed Aug 27 07:00:57 UTC 2014


#29374: Add hook(s) to include other post types in the Activity widget
--------------------------+------------------------------
 Reporter:  samueljmello  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Widgets       |     Version:  3.8
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by SergeyBiryukov):

 > wp_dashboard_recent_posts does not include custom post types (or pages)
 and gives no filter for adding them in manually.

 You can use `pre_get_posts` action as a workaround:
 {{{
 function add_custom_post_types_to_activity_widget( $query ) {
         if ( ! is_admin() || 'dashboard' !== get_current_screen()->id ) {
                 return;
         }

         // Ignore Drafts section in Quick Draft widget
         if ( 'draft' === $query->get( 'post_status' ) ) {
                 return;
         }

         $query->set( 'post_type', get_post_types( array( 'public' => true
 ) ) );
 }
 add_action( 'pre_get_posts', 'add_custom_post_types_to_activity_widget' );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29374#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list