wp_list_table multiple checkboxes

I came up with this…I changed input fields to <input type=”checkbox” id=”%2$s” name=”post[%2$s][]” value=”%2$s” /> <input type=”checkbox” id=”image_%3$s” name=”post[%3$s][]” value=”%2$s” />’ …and added third parameter to column_image function ($item[‘ID’]) function column_image($item){ return sprintf( ‘<input type=”checkbox” id=”image_%3$s” name=”post[%3$s][]” value=”%2$s” />’, /*$1%s*/ $this->_args[‘singular’], /*$2%s*/ ‘yes’, /*$3%s*/ $item[‘ID’] ); } and with that I get array which use … Read more

Get user ID when action row link is clicked

I am passing the user ID as user via the link so its show in my custom list table url. For example, admin.php?page=history_logger&user=3 The user ID is in the query variable. You can access it using a PHP global variable. $_GET[‘user’] $user_id = $_GET[‘user’]; Do not assume that this request (link) came from the Users … Read more

When sorting WP_List_Table, table sorts, but I also get SQL errors

the part ORDER BY $orderby $order LIMIT get translated to ORDER BY asc LIMIT, the columnname that supose to be in $orderby is missing, and there for the sql fail. looks like you want your default value to be ‘title’ $orderby = (isset($_REQUEST[‘orderby’]) && in_array($_REQUEST[‘orderby’], array_keys($this->get_sortable_columns()))) ? $_REQUEST[‘orderby’] : ‘title’; may geuss is that in_array() … Read more

Let Posts be stored in another table

Use save_post action hook as shown below but write custom insert/update queries to save information in a different table. add_action(‘save_post’, ‘save_product_data’); function save_product_data($post_id) { //verify nonce and all other code… $title = $_POST[‘post_title’]; //example variable $wpdb->query( $wpdb->prepare( ” INSERT into wp_product_instore ( post_id, meta_key, meta_value ) values ( $post_id, ‘post_title’, $title )” )); //likewise you … Read more

Wp_List_Table not responsive

i’m using wp-list-table without the (php) class but html only and wanna share my research. There is some stuff to watch if you need a responsive table when building a wp-list-table yourself: add class column-primary to header th and body td. If this class is missing the table gets messy in mobile view add button … Read more

remove $_GET-parameter from WP_List_Table::tablenav

You should consider the POST request method for your action. Otherwise you might try to hijack the set_url_scheme filter with: add_filter( ‘set_url_scheme’, ‘wpse_remove_arg’ ); function wpse_remove_arg( $url ) { return remove_query_arg( ‘do_action_xyz’, $url ); } Then you could try to narrow the scope and only run this on the corresponding table page. Further you could … Read more