0

I am trying to implement a filter button on my wp_list_table, however I need the form where the table is called to be of method=GET so the query parameters for filtering retain their values for pagination. Here is my code where the table is being called:

function calendar_menu(){
    //Prepare Table of elements
    $wp_list_table = new Calendar_List_Table();
    $wp_list_table->prepare_items();
    ?>
    
    <form method='get'>
      <div class="wrap">
        <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
        <?php $wp_list_table->display(); ?>
      </div>
      </form>
    <?php
  }

The page where this table is located at is: wp-admin/admin.php?page=calendar-menu

Whenever the form gets processed,it returns a blank page with the URL to:

wp-admin/admin.php?_wpnonce=eaeb1f772c&_wp_http_referer=%2Fwp-admin%2Fadmin.php%3Fpage%3Dcalendar-menu&action=-1&squad-filter=Swordfish&filterit=Filter+Calendar&paged=1&action2=-1&squad-filter2=

Any idea where the problem could be?

0

Adding following code right inside <table> tag helped me:

<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />

So what's in the value attr will be passed as page param while form sends.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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