Redeem Now
Read More
Read now
Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    hyperlocal-marketplace-guide

    Create Admin tables using WP_List_Table CLASS

    Create Admin tables using WP_List_Table CLASS – In WordPress WP_List_Table Class is used to display data, e.g. users, plugins, comments, or posts.
    Each post type that has a dashboard uses the WP_List_Table class to display data.

    We uses WP_List_Table class so that we can display  custom post type data at wordpress backend.
    In the WordPress dashboard, the tables that displays the posts, pages and user data are all created internally by WordPress using the WP_List_Table class.
    They are used on nearly all default admin pages with lists, and most of the developers often integrate them into their plugins

    WP_List_Table class access is marked as private. That means it is not intended for use by plugin and theme developers as it is subject to change without warning in any future WordPress release. If you would still like to make use of the class, you should make a copy to use and distribute with your own project, or else use it at your own risk.

    Even After this confimation from wordpress.org, the WP_List_Table class has become widely used by plugins and WordPress developers as it provides a reliable, consistent, and semantic way to create custom list tables in WordPress. Till date, no major changes have occurred in this class or are scheduled to occur, so testing your plugin with beta/RC phases of WordPress development should be more than enough to avoid any major issues.

    If you are still feeling risk of using this class a common (and safe) workaround is to make a copy the WP_List_Table class ( /wp-admin/includes/class-wp-list-table.php ) to use and distribute in your plugins, instead of using the original core class. This way, if the core class should ever change, your plugins will continue to work as-is.

    Let’s get started with WP_List_Table class :-

    Register admin menu

    We need to Register admin menu using admin_menu hook

    Using load hook

    We need to create admin menu, sub-menus and using load-hook and current_screen hook we can add option and set help tab for admin menu we have created

    check if WP_List_Table class exists

    Checking if WP_List_Table already exists

    } function custom_detail_page(){ // Add some form and store that data in database and then use that data inside custom_list_page() function }

    Setup Default Columns for wp admin table

    Setting Sortable Columns

    Setting up sortable columns using  get_sortable_columns()

    Setup the Hidden Columns

    Setup Actions for particular Column

    Setup Bulk Actions and Process Bulk Action for Columns

    Get Data From Database

    Setup The Prepared Data and SORT using usort method


    You can also find a complete guide over this class here WordPress Codex

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close