简体   繁体   中英

Make table sortable in Wordpress Admin

I have created a table to show data related to my plugin in wordpress admin.

<th scope="col" id="title" class="manage-column column-title sortable desc" style="">
<a href="<?php echo  get_site_url(); ?>/wp-admin/admin.php?page=Webinar_Reg/allmenu.php&amp;orderby=title&amp;order=asc">
<span>Title</span><span class="sorting-indicator"></span></a></th>

But, when I click on column header(Title) the page refreshes without the title column getting sorted.

I used this link for reference http://pippinsplugins.com/creating-wp-list-tables-by-hand/

You can use the jQuery plugin TableSorter - it is client-side table sorting without need to refresh the page, very flexible and powerful, refresh-less table sort will provide better user experience.

See the demo .

EDIT: In order to use native Wordpress sorting, your table column must have CSS class sorted , when you want it to be sorted (according your reference link):

<th class="manage-column column-title sortable sorted">
  <a href="add_query_args_here">Sortable (and currently sorted)</a>
</th>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM