[WordPress] 外掛分享: List categories

首頁外掛目錄 › List categories
WordPress 外掛 List categories 的封面圖片
6,000+
安裝啟用
★★★★
4.5/5 分(15 則評價)
307 天前
最後更新
問題解決
WordPress 3.3+ v0.5 上架:2014-06-25

內容簡介

這是一個簡單的外掛程式,可以透過簡碼在任何文章或頁面中顯示類別。它基本上是一個簡碼 API 介面,用於 WordPress 的 wp_list_categories 函數。這表示,根據該函數接受的任何參數,都可以將其作為簡碼參數傳遞給「categories」簡碼。

使用方式:

[categories orderby=count]

將顯示所有類別的連結,按每個類別中的文章數量進行排序。

您還可以列出標籤或任何其他 WordPress 稅類。您需要將值傳遞給「taxonomy」參數。例如,要列出標籤:「[categories taxonomy=post_tag title_li="Tags"]。」
默認情況下,使用情況顯示:

不顯示所有類別的連結
按類別名稱升序排序類別列表
顯示無序列表風格
不顯示文章數量
僅顯示有文章的類別
將 title 屬性設置為類別描述
未限制到任何子類別
未使用餵料或餵料圖像
不排除任何類別,包括所有類別
使用 CSS 類後綴「current-cat」顯示活躍的類別
以階層縮進方式顯示類別
將類別顯示為列表標題
不受 SQL 限制(上述未顯示「number」= 0)
顯示(回聲)類別
深度無限制
所有類別。
使用新的 Walker_Category 類的遍歷對象呈現列表

有關用法,請參見wp_list_categories。

類別列表的標記和樣式

從wp_list_categories 官方文檔中獲取。

默認情況下,wp_list_categories() 會在單個列表項目(li)內生成嵌套的無序列表(ul),標題為「類別」。

您可以通過將 title_li 參數設置為空字符串來刪除最外層的項目和列表。您需要自己將輸出包裝在有序列表(ol)或無序列表中(請參閱上面的示例)。如果您不想要列表輸出,請將 style 參數設置為 none。

您可以使用以下 CSS 選擇器設置輸出的樣式:

li.categories { ... } /* 最外層列表項目 */
li.cat-item { ... }
li.cat-item-7 { ... } /* 類別 ID #7,等 */
li.current-cat { ... }
li.current-cat-parent { ... }
ul.children { ... }

在列中顯示類別列表

要將列表輸出為列,您可以使用CSS 的多列。由於默認情況下,列表被列印為帶有「categories」類的無序列表,因此您可以將其添加到您的 CSS 中:

.categories{
column-count: 5;
column-gap: 50px;
}

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.5) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「List categories」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Simple plugin to display categories in any post or page with a shortcode. It’s basically a shortcode API interface to the wp_list_categories WordPress function. This means given any of the parameters accepted by the function, you can pass it in as a shortcode parameter to the categories shortcode.
Usage:
[categories orderby=count]

Will display links to all the categories and order them by number of posts in each category.
You can also list tags or any other WordPress taxonomy. You need to pass a value to the taxonomy parameter. For example to list tags: [categories taxonomy=post_tag title_li="Tags"].
By default, the usage shows:

No link to all categories
Sorts the list of Categories by the Category name in ascending order
Displayed in an unordered list style
Does not show the post count
Displays only Categories with posts
Sets the title attribute to the Category Description
Is not restricted to the child_of any Category
No feed or feed image used
Does not exclude any Category and includes all Categories
Displays the active Category with the CSS Class-Suffix ‘ current-cat’
Shows the Categories in hierarchical indented fashion
Display Category as the heading over the list
No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
Displays (echos) the categories
No limit to depth
All categories.
The list is rendered using a new walker object of the the Walker_Category class

See wp_list_categories for usage.
Markup and Styling of Category Lists
Taken from the wp_list_categories official documentation.
By default, wp_list_categories() generates nested unordered lists (ul) within a single list item (li) titled “Categories”.
You can remove the outermost item and list by setting the title_li parameter to an empty string. You’ll need to wrap the output in an ordered list (ol) or unordered list yourself (see the examples above). If you don’t want list output at all, set the style parameter to none.
You can style the output with these CSS selectors :
li.categories { ... } /* outermost list item */
li.cat-item { ... }
li.cat-item-7 { ... } /* category ID #7, etc */
li.current-cat { ... }
li.current-cat-parent { ... }
ul.children { ... }

For instance, you can remove the bullet points next to each category with:
.cat-item {
list-style-type: none
}

Show categories list in columns
For outputting the list into columns, you can use CSS’s multicolumns. Since by default the list is printed as an unordered list with the “categories” class, you can add this to your CSS:
.categories{
column-count: 5;
column-gap: 50px;
}

延伸相關外掛

文章
Filter
Apply Filters
Mastodon