[英]How to make a sortable admin panel column for a custom field counting the number of page impressions in Wordpress
[英]Make table sortable in Wordpress Admin
我已經創建了一個表格來顯示與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&orderby=title&order=asc">
<span>Title</span><span class="sorting-indicator"></span></a></th>
但是,當我單擊列標題(標題)時,頁面會刷新,而標題列不會被排序。
我使用此鏈接作為參考http://pippinsplugins.com/creating-wp-list-tables-by-hand/
您可以使用jQuery插件TableSorter-它是客戶端表排序,而無需刷新頁面,非常靈活和強大,無需刷新的表排序將提供更好的用戶體驗。
參見演示 。
編輯:為了使用本機Wordpress sorted
,當您希望對其進行排序時(根據您的參考鏈接),您的表列必須具有CSS類sorted
:
<th class="manage-column column-title sortable sorted">
<a href="add_query_args_here">Sortable (and currently sorted)</a>
</th>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.