wp_list_tables bulk actions

If you add a bulk-action, then you have to react on this action. Simply adding a function doesn’t do anything, you have to call it: class WPSE_List_Table extends WP_List_Table { public function __construct() { parent::__construct( array( ‘singular’ => ‘singular_form’, ‘plural’ => ‘plural_form’, ‘ajax’ => false ) ); } public function prepare_items() { $columns = $this->get_columns(); … Read more

Custom Table Column Sortable by Taxonomy Query

To achieve adding a custom sortable column to the WP_List_Table of your post type within the WordPress administration back-end dashboard, you will need to do the following: Replace all occurrences of YOUR-POST-TYPE-NAME with your actual post type name. Replace all occurrences of YOUR-TAXONOMY-NAME with your actual taxonomy name. Replace all occurrences of YOUR COLUMN NAME … Read more

How To Remove These Stuffs From Custom Post Type List Screen?

I don’t know what you mean by dirty way, hopefully not core editing! You can hide it with CSS. Or you can do it with PHP – see below: Hide the views part You can remove the views part with add_filter( ‘views_edit-post’, ‘__return_null’ ); for the post post type on the edit.php screen. The post … Read more

How do I create links at the top of WP_List_table?

As mentioned in the comments, if this is an existing table you wish to add/remove links from, see this answer. If this a custom subclass of WP_List_Table, e.g.: class Wpse56883_WP_List_Table extends WP_List_Table{ //Class methods here } Then you add these links by overriding the get_views() method. This should return an array: array ( id => … Read more

How to create Custom filter options in wp_list_table?

Code class Kv_subscribers_list extends WP_List_Table { function __construct(){ global $status, $page; parent::__construct( array( ‘singular’ => ‘notification’, ‘plural’ => ‘notifications’, ‘ajax’ => false ) ); } protected function get_views() { $status_links = array( “all” => __(“<a href=”#”>All</a>”,’my-plugin-slug’), “published” => __(“<a href=”#”>Published</a>”,’my-plugin-slug’), “trashed” => __(“<a href=”#”>Trashed</a>”,’my-plugin-slug’) ); return $status_links; } function column_default($item, $column_name){ switch($column_name){ case ’email’: case … Read more

How are bulk actions handled in custom list table classes?

Assuming you’re using the standard column_cb() function, the list table will pass the IDs of the selected rows in an array in $_GET, labeled as whatever you assigned to ‘singular’ in the list table’s constructor. Here’s a typical column_cb(): function column_cb($item){ return sprintf( ‘<input type=”checkbox” name=”%1$s[]” value=”%2$s” />’, /*$1%s*/ $this->_args[‘singular’], //Let’s simply repurpose the table’s … Read more