WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to fire on bulk actions inside of an extended WP_List_Table.

I have been adding the following bulk actions to may table's select box but on Apply won't really happens anything

here are how I added my bulk actions

function get_bulk_actions() {
  $actions = array(

        'delete'    => 'Delete',

        'parsing'    => 'Parsen'

  return $actions;

and here is the check box column

function column_cb($item) {

    return sprintf(

            '<input type="checkbox" name="record[]" value="%d" />', $item['Round']

share|improve this question
up vote 2 down vote accepted

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() {

                'singular' => 'singular_form',
                'plural'   => 'plural_form',
                'ajax'     => false


    public function prepare_items() {

        $columns  = $this->get_columns();
        $sortable = $this->get_sortable_columns();
        $hidden   = array( 'id' );

        $this->_column_headers = array( $columns, $hidden, $sortable );



    public function get_columns() {

        return array(
            'cb'    => '<input type="checkbox" />', // this is all you need for the bulk-action checkbox
            'id'    => 'ID',
            'date'  => __( 'Date', 'your-textdomain' ),
            'title' => __( 'Title', 'your-textdomain' ),


    public function get_sortable_columns() {

        return array(
            'date'  => array( 'date', false ),
            'title' => array( 'title', false ),


    public function get_bulk_actions() {

        return array(
                'delete' => __( 'Delete', 'your-textdomain' ),
                'save'   => __( 'Save', 'your-textdomain' ),


    public function process_bulk_action() {

        // security check!
        if ( isset( $_POST['_wpnonce'] ) && ! empty( $_POST['_wpnonce'] ) ) {

            $nonce  = filter_input( INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING );
            $action = 'bulk-' . $this->_args['plural'];

            if ( ! wp_verify_nonce( $nonce, $action ) )
                wp_die( 'Nope! Security check failed!' );


        $action = $this->current_action();

        switch ( $action ) {

            case 'delete':
                wp_die( 'Delete something' );

            case 'save':
                wp_die( 'Save something' );

                // do nothing or something else



In prepare_items()we call process_bulk_action(). So on your backend page you will have something like this:

$table = new WPSE_List_Table();

printf( '<div class="wrap" id="wpse-list-table"><h2>%s</h2>', __( 'Your List Table', 'your-textdomain' ) );

echo '<form id="wpse-list-table-form" method="post">';

$page  = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRIPPED );
$paged = filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_NUMBER_INT );

printf( '<input type="hidden" name="page" value="%s" />', $page );
printf( '<input type="hidden" name="paged" value="%d" />', $paged );

$table->prepare_items(); // this will prepare the items AND process the bulk actions

echo '</form>';

echo '</div>';

At first you create an instance of your list-table class. Then you create a formular and call prepare_items(). With this call, the bulk actions will be processed because we call the method process_bulk_action() inside prepare_items().

In the example above, we use post as method to send the data. So we can grab the bulk action from the post array if we didn't want to process the bulk actions inside the class (or by other reasons).

// this is the top bulk action!!
$action = ( isset( $_POST['action'] ) ) ?
    filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRIPPED ) : 'default_top_bulk_action';

// this is the bottom bulk action!!
$action2 = ( isset( $_POST['action2'] ) ) ? 
    filter_input( INPUT_POST, 'action2', FILTER_SANITIZE_STRIPPED ) : 'default_bottom_bulk_action';

switch ( $action ) {}
switch ( $action2 ) {}

You can grab the bulk action anywhere you want from the post/get array (depending on what method was used to send the data).

share|improve this answer

this is what I have found on several websites. It still isn't working for me, but it used to work when I still had the sample data in my custom list table.

  function process_bulk_action() {

    //Detect when a bulk action is being triggered...
    if( 'delete'===$this->current_action() ) {
        wp_die('Items deleted (or they would be if we had items to delete)!');

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.