Skip to navigation
WP_List_Table for my plugin. How to build a table list in a wordpress plugin
08.07.23
## you can use the build in WordPress table and for this, you need * 1. Class what extends the WordPress table class * 3. Function inside this Class * 1. Data Set Example: ```php 1,'booktitle' => 'Quarter Share', 'author' => 'Nathan Lowell', 'isbn' => '978-0982514542'), array('ID' => 2, 'booktitle' => '7th Son: Descent','author' => 'J. C. Hutchins', 'isbn' => '0312384378'), array('ID' => 3, 'booktitle' => 'Shadowmagic', 'author' => 'John Lenahan', 'isbn' => '978-1905548927'), array('ID' => 4, 'booktitle' => 'The Crown Conspiracy', 'author' => 'Michael J. Sullivan', 'isbn' => '978-0979621130'), array('ID' => 5, 'booktitle' => 'Max Quick: The Pocket and the Pendant', 'author' => 'Mark Jeffrey', 'isbn' => '978-0061988929'), array('ID' => 6, 'booktitle' => 'Jack Wakes Up: A Novel', 'author' => 'Seth Harwood', 'isbn' => '978-0307454355') ); function get_columns(){ $columns = array( 'booktitle' => 'Title', 'author' => 'Author', 'isbn' => 'ISBN' ); return $columns; } function prepare_items() { $columns = $this->get_columns(); $hidden = array(); $sortable = array(); $this->_column_headers = array($columns, $hidden, $sortable); $this->items = $this->example_data;; } function column_default( $item, $column_name ) { switch( $column_name ) { case 'booktitle': case 'author': case 'isbn': return $item[ $column_name ]; default: return print_r( $item, true ) ; //Show the whole array for troubleshooting purposes } } } $l = new My_Class(); $l->prepare_items(); $l->display(); ?> ```
https://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/
Reply
Anonymous
Information Epoch 1742187937
Small is beautiful.
Home
Notebook
Contact us