內容簡介
Subpage Listing 可以充分利用 WordPress Pages 的層級結構,生成其下(子頁面)頁面的導航樹。
例如,假設您有一個名為「Parent」的父頁面。現在,假設您有 3 個在「Parent」下的頁面,分別為「Child1」、「Child2」和「Child3」。現在,假設在「Child2」下有 2 個頁面,分別為「Grandchild1」和「Grandchild2」。
Subpage Listing 會為「Parent」創建一個導航樹,看起來像這樣:
Child1
Child2
Grandchild1
Grandchild2
Child3
這使您可以非常輕鬆地創建一個複雜的層次結構,可以瀏覽。
高級用法
空白頁面會自動給出一個導航樹。這使您可以快速創建「容器」頁面(您只需填寫標題,並選擇頁面的父頁面)。
如果您想手動插入導航樹(即,用您選擇的文本包圍),請使用 Write Page 畫面上顯示的「Subpage Listing」快標籤(抱歉,此時沒有 RTE 支持)。這將插入標籤:,並將其替換為子頁面的清單。
注意:手動插入標籤時,請確保標籤上面和下面都有空行,以確保 WordPress 正確處理您的周圍段落。
版本 0.6 是一個大更新,新增了許多新功能。添加了顯示當前頁面父頁面的能力,以及顯示當前頁面兄弟頁面的能力。您還可以抑制子頁面的顯示,並僅顯示兄弟、父親或兩者。要在帖子內使用這些功能,請使用此語法:第一個「參數」是您要顯示的深度。您可以將其設置為 0,以抑制子項顯示。第二個「參數」是顯示父頁面的布爾開關。第三個「參數」是顯示兄弟頁面的布爾開關。所有這些都是可選的,但是如果您想設置第二個「參數」,您也必須設置第一個,如果您想設置第三個,您必須設置全部三個。
也有一個新功能可以在您的模板中使用。許多人希望在側邊欄中顯示子頁面或兄弟頁面,因此現在可以這樣做。 <?php txfx_wp_subpages(); ?> 是最基本的形式,但它可以接受很多參數。
<?php txfx_wp_subpages(5, false, false, '<ul>', '</ul>', true); ?> 將顯示 5 層(第一個參數),隱藏父項(第二個參數),隱藏兄弟項(第三個參數),將整個東西包裝在「<ul>」和「</ul>」中(第四和第五個參數),並將結果輸出(第六個參數)。這恰好是默認設置,我剛剛演示了一下。
外掛標籤
開發者團隊
原文外掛簡介
Subpage Listing allows you to take full advantage of WordPress Pages’ hierarchy by generating a navigational tree of the pages below them (subpages).
For example, say you have a parent page called “Parent.” Now, say you have 3 pages under “Parent,” called “Child1,” “Child2,” and “Child3.” Now, say that you have 2 pages under “Child2” called “Grandchild1” and “Grandchild2.”
Subpage Listing would create a navigation tree for “Parent” that looks like this:
Child1
Child2
Grandchild1
Grandchild2
Child3
This allows you to very easily create a complex hierarchical structure that can be browsed.
Advanced Usage
Blank pages will automatically be given a navigation tree. This allows you to quickly create “container” pages (all you do is fill in a title, and choose the page’s parent.)
If you would like to insert the navigational tree manually (that is, surrounded by text of your choosing), use the “Subpage Listing” quicktag that will show up on the Write Page screen (sorry, no RTE support at this time). This will insert the tag: which will be replaced by the listing of the subpages.
Note: when inserting the tag manually, make sure that there is a blank line both above and below the tag, so as to ensure proper handling of your surrounding paragraphs by WordPress.
Version 0.6 was a massive update that added a bunch of new functionality. The ability to show the current page’s parent has been added, as well as the ability to show the current page’s siblings. You can also suppress the showing of children, and show only siblings, parents, or both. To use these features within a post, use this syntax: The first “parameter” is the depth you want to show. You can set this to 0 to suppress display of children. The second “parameter” is a boolean switch for display of the parent page. The third “parameter” is a boolean switch for display of sibling pages. All are optional, although if you want to set the second “parameter”, you also have to set the first, and if you want to set the third, you have to set all three.
There is also a new function for use in your templates. Many people wanted to show subpages or siblings in their sidebar, so now you can do that. is the most basic form, but it can take many parameters.
', '
', true); ?> will show 5 pages deep (first parameter), hide the parent (second parameter), hide the siblings (third parameter), wrap the whole thing in '
- ' and '
' (fourth and fifth parameters), and will echo the result (sixth parameter). These happen to be the default settings, that I have just illustrated.
