[WordPress] 外掛分享: Custom Taxonomy Sort

前言介紹

  • 這款 WordPress 外掛「Custom Taxonomy Sort」是 2011-07-03 上架。
  • 目前有 500 個安裝啟用數。
  • 上一次更新是 2011-12-13,距離現在已有 4891 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.1 以上版本才可以安裝。
  • 有 14 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

tollmanz |

外掛標籤

sort | category | taxonomy |

內容簡介

令人驚訝的是,WordPress 不提供自定義排序分類法的機制。分類法只能以名稱或 id 排序,無法自定義。Custom Taxonomy Sort 讓普通用戶有機會定義並顯示特定順序的項目。安裝 Custom Taxonomy Sort 後,每個分類法項目將有與其關聯的「tax-order」值。執行以下操作指定排序:

前往任何分類法添加或編輯畫面(例如,wp-admin/edit-tags.php?taxonomy=category)
填寫「序號」欄位的數值。預設為升序排序(即從小到大排序,例如 1、2、3)。這些值可以在新增分類法畫面、編輯分類法畫面或透過「快速編輯」面板中新增。
觀察所有項目根據指定的順序自動排序

Custom Taxonomy Sort 會自動將排序應用於所有顯示該分類法項目的實例。您只需定義該順序即可。

手動模式

除了自動排序項目之外,Custom Taxonomy Sort 還可以允許開發人員覆蓋自動排序,以更細緻地控制在 WordPress 不同部分顯示項目的方式。手動模式可以通過在 Custom Taxonomy Sort 設置頁面(wp-admin/options-general.php?page=custom-taxonomy-sort-settings)中將「自動排序」更改為「關閉」來啟動。切換「自動排序」為「關閉」後,項目將不再按照自定義順序自動排序。取而代之的是,可以在「orderby」引數的新參數中調用自定義排序順序。Custom Taxonomy Sort 允許您使用以下引數使用「get_terms」來訪問自定義排序項目清單

現在,您的項目只會按照您指定的順序在想要按此順序排序的地方排序。顯示項目的所有其他實例將恢復 WordPress 默認的按名稱排序。此外,您可以通過添加「order」引數特別將項目按照升序('ASC'; 預設,例如 1、2、3)或降序('DESC';例如 3、2、1)排序。

鳴謝

感謝 Jacob M Goldman 的優秀 Simple Term Meta 外掛,使得程式編寫期間的項目元素非常簡單。
感謝 hydrowire 指出 1.1.1 中已修復的錯誤
感謝“Mosey”指出了不適用於自定義分類法的順序排序錯誤
感謝 DUCK__BOY1981 指出了欄位值被不適當覆蓋的錯誤
感謝 @martindj 指出了欄位值不正確返回的錯誤

原文外掛簡介

Surprisingly, WordPress does not provide a mechanism for sorting taxonomies by a custom defined order. Taxonomies can only be sorted by name or id. Custom Taxonomy Sort allows the average user a mechanism to define and display terms in a specified order. After installing Custom Taxonomy Sort, each taxonomy term will have the ability to have a “tax-order” value associated with it. This order is specified by doing the following:

Go to any taxonomy add or edit screen (e.g., wp-admin/edit-tags.php?taxonomy=category)
Fill in a numeric value for the “Order” field. By default, the order will be ascending, meaning it will sort from low to high (e.g., 1, 2, 3). These values can be added on the Add Taxonomy screen, the Edit Taxonomy screen, or through the Quick Edit panel.
Observe all of your terms automagically being sorted in the order you specified

Custom Taxonomy Sort automatically applies the sort order to all instances in which the terms are displayed. All you need to do is define that order.
Manual Mode
In addition to automatically sorting the terms, Custom Taxonomy Sort allows developers to override the automatic sort to offer finer control over how terms are displayed in different parts of WordPress. Manual mode can be started by changing “Automatic Sort” to “Off” in the Custom Taxonomy Sort Settings page (wp-admin/options-general.php?page=custom-taxonomy-sort-settings). Once “Automatic Sort” is switched to “Off”, the terms will no longer be sorted automatically by the custom order. Instead, the custom sort order can be envoked with a new parameter for the “orderby” argument. Custom Taxonomy Sort allows you to use the following argument to access a custom sorted list of terms using “get_terms”

Voila! Now, your terms will only be sorted by the specified order in the places that you want it sorted in this order. All other instances of displaying terms will revert to WordPress’ default of sorting the terms by name. Additionally, you can specifically have the terms sort in ascending (‘ASC’; default; e.g., 1, 2, 3) or descending (‘DESC’; e.g., 3, 2, 1) order by adding the “order” argument.

Acknowledgements

Thanks to Jacob M Goldman for his excellent Simple Term Meta plugin, which made programming the term meta quite simple.
Thanks to hydrowire for pointing out a bug fixed in 1.1.1
Thanks to “Mosey” for pointing out a bug with a situation in which order did not work for a custom taxonomy
Thanks to DUCK__BOY1981 for pointing out a bug where the column values where overridden inappropriately
Thanks to @martindj for pointing out a bug where the column value returned incorrectly

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Custom Taxonomy Sort」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.0.1 | 1.1.1 | 1.1.2 | 1.1.3 | 1.1.4 | 1.1.5 | trunk |

延伸相關外掛(你可能也想知道)

  • FileBird – WordPress Media Library Folders & File Manager 》Media Folder 是史上最佳的 WordPress 外掛,可讓您使用資料夾對媒體庫進行分類。, 我們可以使用拖放式組織方式整理 WordPress 媒體庫資料夾。, 試用 | 升級...。
  • Pages with category and tag 》在頁面中新增分類和標籤。。
  • WordPress Tag, Category, and Taxonomy Manager – AI Autotagger 》axoPress allows you to show a customizable display of the terms assigned to the current post. You can choose which taxonomy and which format to dis...。
  • Search & Filter 》Search & Filter 是一款簡單的 WordPress 搜尋和篩選外掛程式,是 WordPress 搜尋框的進階版。, 您可以透過類別、標籤、自訂分類、文章類型、發佈日期或...。
  • Remove Category URL 》這個外掛可以徹底將 WordPress 網站的連結結構中的「/category/」去除(例如:從 mydomain.com/category/my-category/ 變成 mydomain.com/my-category/ )。,...。
  • Category Posts Widget 》Category Posts Widget是一個輕巧的小工具,設計用於一件事並且做得很好:顯示特定類別中最新的文章。, 基於詞語和類別的文章小工具, 這個免費小工具的高級版...。
  • Media Library Categories 》此外掛可允許在 WordPress 媒體庫中使用分類。啟用後,媒體庫中會顯示下拉式的分類清單。, 您可以使用大量動作進行多項目的分類更改、新增或移除分類。, 在使...。
  • Add Category to Pages 》「Add Category to Pages」外掛讓你能夠快速新增 WordPress 頁面的分類和標籤。, 這個外掛能夠為 WordPress 頁面加上 WordPress 分類的功能。, 啟用外掛後,...。
  • WP No Base Permalink 》該外掛能夠將分類基礎從您的分類永久連結中移除 (可選)。默認情況下啟用。, 該外掛能夠從您的分類永久連結中移除父級分類 (可選)。, 該外掛能夠將標籤基礎從...。
  • Advance WordPress Search Plugin 》WooCommerce Advance Product Search是WooCommerce最快的搜尋外掛程式,支援AJAX搜尋和搜尋結果頁面顯示。, TH Advance Product Search是一個強大的基於AJAX...。
  • Term Management Tools 》請注意,此外掛需要至少 PHP 7.1。, 如果您需要重新組織標籤和分類,此外掛可以讓您更輕鬆地進行操作。它在條目管理頁面的“批次操作”下拉菜單中添加了三個新...。
  • Taxonomy Images 》在你的主題中顯示圖像, 有一些過濾器可以在你的主題中使用,來顯示此外掛創建的圖像關聯。請閱讀以下詳細信息。, 顯示代表術語檔案庫的單個圖像, 以下過濾器...。
  • PS Taxonomy Expander 》PS Taxonomy Expander 可以讓您更輕鬆地在編輯文章時使用類別、標籤和自訂分類法。, 功能, , 啟用將分類法核取方塊變成有階層的單選按鈕功能。, 讓您在 WordP...。
  • Parent Category Toggler 》當選擇子目錄時,自動切換到父目錄。, 1.3.4, , 相容更新 WordPress 4.8。, , 1.3.3, , 測試過 WP 4.4。, , 1.3.2, , 只在 wp-admin 的文章 (也包括自訂文章...。
  • List Custom Taxonomy Widget 》清單自訂分類小工具是一種快速且簡單的方式,可以顯示自訂分類。只需從自動填充的清單中選擇要顯示的分類名稱即可。您還可以設置小工具要顯示的標題。可以將...。

文章
Filter
Mastodon