There are a variety of administrative WordPress hooks that are applied on a page by page basis. Some good examples can be found in the WP_List_Table object.
Example hooks based on screen ID
- manage_{$screen->id}_columns – Add or delete columns from various administrative pages.
- views_{$screen->id} – Display the number of objects belonging to each status type. (See below)
- bulk_actions-{$screen->id} – As of WordPress 3.2 this filter can only be used to remove bulk actions.
- manage_{$screen->id}_sortable_columns – Filter list of all, hidden and sortable columns.
Get the WordPress Screen ID of a Page
An easy way to get your WordPress screen ID is to use the current_screen filter.
// Add to the admin_init action hook add_filter('current_screen', 'my_current_screen' ); function my_current_screen($screen) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return $screen; print_r($screen); return $screen; }
Once the code above is in place, you can simply visit the page(s) of choice and get their screen ID.
Add Filters to Multiple Screens
We can also use the current_screen hook to add in column, view, or bulk-action filters to all or multiple chosen screens.
function my_current_screen($screen) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return $screen; add_filter('views_'.$screen->id, 'my_views_filter' ); return $screen; } function my_views_filter($links) { $links['shibashake'] = '<a href="http://shibashake.com">Visit ShibaShake.com</a>'; return $links; }
The code above adds a ShibaShake site link to all administrative pages that show number of objects by status type.
This multiple-screen-add functionality will be especially useful when we can append entries to the bulk-action drop down menu.
Benedikt says
Is there a possibility to add a bulk_actions in an other way???
Cédric G. says
Hi
Great article (and great website, which is in my WordPress favorites for a long time !)
Do you know how to add comboboxes to taxonomies applied to custom post types (just behind the multiple screens filters) ?
I haven’t found any resource about this function 🙁
With my best regards
Cédric, from France
ShibaShake says
Hmmm, do you mean you want to add your own HTML input boxes to a custom taxonomy edit screen? I haven’t looked at this recently, but I would check out the add_tag_form_fields or $taxonomy_add_form_fields action hooks.