WordPress: Template Tags/wp list pages:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == The Template Tag, '''wp_list_pages()''', displays a list of WordPress WordPress:Pages as links. It is often used to customize the [[WordPress:Customizing_Your_Sideba...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==
The Template Tag, '''wp_list_pages()''', displays a list of WordPress [[WordPress:Pages]] as links. It is often used to customize the [[WordPress:Customizing_Your_Sidebar|Sidebar]] or [[WordPress:Designing_Headers|Header]], but may be used in other [[WordPress:Templates]] as well.
The Template Tag, '''wp_list_pages()''', displays a list of WordPress [[WordPress:Pages]] as links. It is often used to customize the [[WordPress:Customizing_Your_Sidebar|Sidebar]] or [[WordPress:Designing_Headers|Header]], but may be used in other [[WordPress:Templates]] as well.
模板标签,'''wp_list_网页()''',显示了WordPres[[WordPress:Pages|网页]]的一个列表,作为一列链接。'''wp_list_pages()'''通过用来自定义[[WordPress:Customizing_Your_Sidebar|工具条]]或者 [[WordPress:Designing_Headers|标头]],但是也可能在其它的[[WordPress:Templates|模板]]中使用。


This [[WordPress:Template Tags|Template Tag]] is available for WordPress versions 1.5 and newer.
This [[WordPress:Template Tags|Template Tag]] is available for WordPress versions 1.5 and newer.
WordPress1.5版本以及更新的版本中拥有这个[[WordPress:Template Tags|模板标签]]。


== Usage ==
== Usage ==
%%% <?php wp_list_pages('arguments'); ?> %%%
%%% <?php wp_list_pages('arguments'); ?> %%%
== 用法==
%%% <?php wp_列表_网页('参数'); ?> %%%


== Examples ==
== Examples ==
== 例子==


===Default Usage===
===Default Usage===
===默认用法===
<pre>
<pre>
$defaults = array(
$defaults = array(
第20行: 第31行:
     'echo'        => 1,
     'echo'        => 1,
     'authors'    => '',
     'authors'    => '',
    'sort_column' => 'menu_order, post_title');
</pre>
<pre>
$defaults = array(
    '深度'      => 0,
    '显示_日期'  => '',
    '日期_格式' => 得到_选项('日期_格式'),
    'child_of'    => 0,
    '删除'    => '',
    'title_li'    => __('Pages'),
    'echo'        => 1,
    '作者'    => '',
     'sort_column' => 'menu_order, post_title');
     'sort_column' => 'menu_order, post_title');
</pre>
</pre>


By default, the usage shows:
By default, the usage shows:
默认情况下,用法显示:
* All Pages and sub-pages are displayed (no depth restriction)
* All Pages and sub-pages are displayed (no depth restriction)
*显示了所有的网页和子网页(没有层级限制)
* Date created is not displayed
* Date created is not displayed
*不显示创建的日期
* Is not restricted to the child_of any Page
* Is not restricted to the child_of any Page
*不限制到任何网页的子网页
* No pages are excluded
* No pages are excluded
*不删除任何网页
* The title of the pages listed is "Pages"
* The title of the pages listed is "Pages"
*网页的标题列为"网页"
* Results are echoed (displayed)
* Results are echoed (displayed)
*结果得到反映(显示)
* Is not restricted to any specific author
* Is not restricted to any specific author
*文章不限制为某个作者的
* Sorted by Page Order then Page Title.
* Sorted by Page Order then Page Title.
*有网页顺序分类然后有网页标题分类。
* Sorted in ascending order (not shown in defaults above)
* Sorted in ascending order (not shown in defaults above)
*以升序分类(不在上面的默认设置中显示)
* Pages displayed in a hierarchical indented fashion (not shown in defaults above)
* Pages displayed in a hierarchical indented fashion (not shown in defaults above)
*网页以层级嵌套的方式显示(不在上面的默认设置中显示)
* Includes all Pages (not shown in defaults above)
* Includes all Pages (not shown in defaults above)
*包含所有的网页(不在上面的默认设置中显示)
* Not restricted to Pages with specific meta key/meta value (not shown in defaults above)
* Not restricted to Pages with specific meta key/meta value (not shown in defaults above)
*不限制为拥有特别的meta key/meta参数值的网页(不显示在上述的默认设置中)
   
   
  wp_list_pages();
  wp_list_pages();
wp_列表_网页();


=== Hiding or Changing the List Heading ===
=== Hiding or Changing the List Heading ===
=== 隐藏或者更改列表标头===
The default heading of the list ("Pages") of Pages generated by ''wp_list_pages'' can be hidden by passing a null or empty value to the '''title_li''' parameter. The following example displays no heading text above the list.
The default heading of the list ("Pages") of Pages generated by ''wp_list_pages'' can be hidden by passing a null or empty value to the '''title_li''' parameter. The following example displays no heading text above the list.
''wp_列表_网页''产生的网页("网页")列表的默认标题,可以通过向'''title_li''' 参数传递一个零或者空参数值,得到隐藏。下面的例子显示了列表上方没有标题文本。


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第48行: 第114行:
&lt;?php<br />
&lt;?php<br />
wp_list_pages('title_li='); ?&gt; <br />  
wp_list_pages('title_li='); ?&gt; <br />  
&lt;/ul&gt;
</tt>
</div>
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_列表_网页('title_li='); ?&gt; <br />
&lt;/ul&gt;
&lt;/ul&gt;
</tt>
</tt>
第53行: 第131行:


In the following example, only Pages with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word "Poetry", with a heading style of <tt><nowiki><h2></nowiki></tt>:  
In the following example, only Pages with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word "Poetry", with a heading style of <tt><nowiki><h2></nowiki></tt>:  
在下面的例子中,只有ID是9,5,23的网页包含在列表中而且标题文本被更改为"诗",标头形式为<tt><nowiki><h2></nowiki></tt>:


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第60行: 第140行:
&lt;?php<br />
&lt;?php<br />
wp_list_pages('include=5,9,23&title_li=&lt;h2&gt;' . __('Poetry') . '&lt;/h2&gt;' ); ?&gt; <br />  
wp_list_pages('include=5,9,23&title_li=&lt;h2&gt;' . __('Poetry') . '&lt;/h2&gt;' ); ?&gt; <br />  
&lt;/ul&gt;
</tt>
</div>
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('包含=5,9,23&title_li=&lt;h2&gt;' . __('诗') . '&lt;/h2&gt;' ); ?&gt; <br />
&lt;/ul&gt;
&lt;/ul&gt;
</tt>
</tt>
第65行: 第155行:


=== List Pages by Page Order ===
=== List Pages by Page Order ===
=== 根据网页顺序列出网页 ===
The following example lists the Pages in the order defined by the '''Page Order''' settings for each Page in the [[WordPress:Administration_Panels#Write_Page|Write]] > [[WordPress:Write_Page_SubPanel|Page]] administrative panel.
The following example lists the Pages in the order defined by the '''Page Order''' settings for each Page in the [[WordPress:Administration_Panels#Write_Page|Write]] > [[WordPress:Write_Page_SubPanel|Page]] administrative panel.
下面的例子,根据[[WordPress:Administration_Panels#Write_Page|写]] > [[WordPress:Write_Page_SubPanel|网页]] 管理面板中设置的每个网页的'''排序'''来列出网页。
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('sort_column=menu_order'); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第78行: 第183行:


If you wanted to sort the list by Page Order and display the word "Prose" as the list heading (in h2 style) on a Sidebar, you could add the following code to the sidebar.php file:
If you wanted to sort the list by Page Order and display the word "Prose" as the list heading (in h2 style) on a Sidebar, you could add the following code to the sidebar.php file:
如果你想要根据网页顺序给列表分类,而且在工具条上显示"散文"作为列表标题(以h2样式),你可以添加以下的代码到sidebar.php文件上:
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('sort_column=menu_order&title_li=&lt;h2&gt;' . __('Prose') . '&lt;/h2&gt;' ); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第90行: 第209行:


Using the following piece of code, the Pages will display without heading and in ''Page Order'':
Using the following piece of code, the Pages will display without heading and in ''Page Order'':
使用下面的这些代码,网页会以''网页顺序''显示,而且还没有标题:
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('sort_column=menu_order&title_li='); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第102行: 第234行:


=== Sort Pages by Post Date===
=== Sort Pages by Post Date===
=== 根据文章日期给网页分类===
This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.
This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.
这个例子显示了网页根据(创建)日期分类,而且在每个网页列表item的旁边显示了日期。
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('sort_column=post_date&show_date=created'); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第115行: 第261行:


=== Exclude Pages from List ===
=== Exclude Pages from List ===
=== 从列表中删除网页===
Use the '''exclude''' parameter hide certain Pages from the list to be generated by ''wp_list_pages''.  <!-- '''Note''': Page numbers must be in ascending order (i.e. <tt>'exclude=17,38'</tt> and not <tt>'exclude=38,17'</tt>).  Note this isn't true at least as 2.1.3 -->
Use the '''exclude''' parameter hide certain Pages from the list to be generated by ''wp_list_pages''.  <!-- '''Note''': Page numbers must be in ascending order (i.e. <tt>'exclude=17,38'</tt> and not <tt>'exclude=38,17'</tt>).  Note this isn't true at least as 2.1.3 -->
使用'''删除'''参数隐藏''wp_list_pages''产生的列表中的某个网页。<!-- '''注''': 网页数字必须以升序=排列(例如<tt>'删除=17,38'</tt> 而不 <tt>'删除=38,17'</tt>).  注意至少这个对于2.1.3 是行不通的-->
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('exclude=17,38' ); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第128行: 第287行:


=== Include Pages in List ===
=== Include Pages in List ===
=== 在列表中包含网页===
To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the '''include''' parameter. <!--'''Note''': Page numbers must be in ascending order (i.e. <tt>'include=7,13,26,35'</tt> and not <tt>'include=35,7,26,13'</tt>).  this does not seem to be true at least at 2.1.3-->
To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the '''include''' parameter. <!--'''Note''': Page numbers must be in ascending order (i.e. <tt>'include=7,13,26,35'</tt> and not <tt>'include=35,7,26,13'</tt>).  this does not seem to be true at least at 2.1.3-->
在一个列表中只包含某个特别的网页,例如,ID数字为35,7,26和13的网页,使用'''包含'''参数。<!--'''注''': 网页数字必须以升序排列(例如 <tt>'包含=7,13,26,35'</tt> 而不是<tt>'包含=35,7,26,13'</tt>)。  至少2.1.3这样的序列是行不通的-->


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第136行: 第297行:
&lt;?php<br />
&lt;?php<br />
wp_list_pages('include=7,13,26,35&title_li=&lt;h2>' . __('Pages') . '&lt;/h2>' ); ?&gt; <br />  
wp_list_pages('include=7,13,26,35&title_li=&lt;h2>' . __('Pages') . '&lt;/h2>' ); ?&gt; <br />  
&lt;/ul&gt;
</tt>
</div>
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('包含=7,13,26,35&title_li=&lt;h2>' . __('Pages') . '&lt;/h2>' ); ?&gt; <br />
&lt;/ul&gt;
&lt;/ul&gt;
</tt>
</tt>
第141行: 第312行:


=== List Sub-Pages (versions prior to Wordpress 2.0.1)===
=== List Sub-Pages (versions prior to Wordpress 2.0.1)===
===列出子网页(Wordpress 2.0.1之前的版本)===
Put this inside the <tt>the_post()</tt> section of the page.php template of your WordPress theme after <tt>the_content()</tt>, or put it in a copy of the page.php template that you use for pages that have sub-pages:
Put this inside the <tt>the_post()</tt> section of the page.php template of your WordPress theme after <tt>the_content()</tt>, or put it in a copy of the page.php template that you use for pages that have sub-pages:
将这个放到<tt>the_内容()</tt>后的WordPress主题的page.php 模板的<tt>the_文章()</tt>部分的内部,或者将这个放到page.php模板的一个拷贝中,你为拥有子网页的网页使用这个page.php模板:
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
global $id;
// teensy bit insane, sorry <br />
$date_format = '<\b\r /><\s\p\a\n '.
'\s\t\y\l\e="\f\o\n\t-\s\i\z\e: \s\m\a\l\l\e\r">'.
'\l\a\s\t\m\o\d Y-n-j</\s\p\a\n>';
wp_list_pages("title_li=&child_of=$id&show_date=modified<br />
&date_format=$date_format"); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第160行: 第354行:


<span style="color:#c00;">NOTE: This example does not work with Wordpress 2.0.1 or newer if placed in a page template because the global $id is not set. Use the following code</span>
<span style="color:#c00;">NOTE: This example does not work with Wordpress 2.0.1 or newer if placed in a page template because the global $id is not set. Use the following code</span>
<span style="color:#c00;">注:如果这个例子放到了一个网页模板中,在WordPress2.0.1或者更新的版本中不能够运行,因为没有设置全局$id。使用下面的代码</span>


=== List Sub-Pages (Wordpress 2.0.1 or newer)===
=== List Sub-Pages (Wordpress 2.0.1 or newer)===
=== 列出子网页 (Wordpress 2.0.1 或者更新的版本)===
NOTE: Requires an HTML tag (either <tt><nowiki><ul></nowiki></tt> or <tt><nowiki><ol></nowiki></tt>) even if  there are no subpages. Keep this in mind if you are using css to style the list.
NOTE: Requires an HTML tag (either <tt><nowiki><ul></nowiki></tt> or <tt><nowiki><ol></nowiki></tt>) even if  there are no subpages. Keep this in mind if you are using css to style the list.
注意:即使没有子网页,也需要一个HTML标签(<tt><nowiki><ul></nowiki></tt> 或者<tt><nowiki><ol></nowiki></tt>)。当你使用css设计列表的时候,要牢记这一点。
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;ul&gt; <br />
&lt;?php<br />
wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified<br />
&date_format=$date_format'); ?&gt; <br />
&lt;/ul&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第176行: 第389行:


The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:
The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:
只有当前的网页拥有子网页的时候,下面的例子才会产生一个列表(子网页是指定当前网页为母网页的网页):
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;?php<br />
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');<br />
if ($children) { ?&gt; <br />
&lt;ul&gt; <br />
&lt;?php echo $children; ?&gt; <br />
&lt;/ul&gt; <br />
&lt;?php } ?&gt;
</tt>
</div>


<div style="padding: 1em; border: 1px dashed #2f6fab;  
<div style="padding: 1em; border: 1px dashed #2f6fab;  
第191行: 第419行:


=== List subpages even if on a subpage ===
=== List subpages even if on a subpage ===
=== 即使没有子网页,也列出子网页 ===
The above examples will only show the children from the parent page, but not when actually on a child page.  This code will show the child pages, and only the child pages, when on a parent or on one of the children.
The above examples will only show the children from the parent page, but not when actually on a child page.  This code will show the child pages, and only the child pages, when on a parent or on one of the children.
上述的例子指示显示了来自于母网页的子网页,但是并不是真正地在一个子网页上,这个代码会显示子网页,而且只有子网页在母网页上或者在其中的一个子网页上时,参会显示。


** warning ** This code will not work if placed after a widget block in the sidebar.
** warning ** This code will not work if placed after a widget block in the sidebar.
** 警醒 ** 如果将这个代码放到一个工具条上的一个widget 块上时,这个代码就不会运行。
<div style="padding: 1em; border: 1px dashed #2f6fab;
color: Black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.9em;">
<tt>
&lt;?php<br />
if($post->post_parent)<br />
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else<br />
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");<br />
if ($children) { ?&gt;<br />
&lt;ul&gt; <br />
&lt;?php echo $children; ?&gt; <br />
&lt;/ul&gt; <br />
&lt;?php } ?&gt;
</tt>
</div>




第213行: 第465行:


=== Markup and styling of page items ===
=== Markup and styling of page items ===
=== 网页items的标记和样式===


By default, '''wp_list_pages()''' generates a nested, unordered list of WordPress [[WordPress:Pages]] created with the [[WordPress:Administration_Panels#Write_Page|Write]] > [[WordPress:Write_Page_SubPanel|Page]] admin panel. You can remove the outermost item (<tt>li.pagenav</tt>) and list (<tt>ul</tt>) by setting the <var>title_li</var> parameter to an empty string.
By default, '''wp_list_pages()''' generates a nested, unordered list of WordPress [[WordPress:Pages]] created with the [[WordPress:Administration_Panels#Write_Page|Write]] > [[WordPress:Write_Page_SubPanel|Page]] admin panel. You can remove the outermost item (<tt>li.pagenav</tt>) and list (<tt>ul</tt>) by setting the <var>title_li</var> parameter to an empty string.


All list items (<tt>li</tt>) generated by '''wp_list_pages()''' are marked with the class <tt>page_item</tt>. When '''wp_list_pages()''' is called while displaying a Page, the list item for that Page is given the additional class <tt>current_page_item</tt>.
默认情况下,'''wp_列表_网页()'''产生一个无序的,嵌套的WordPress[[WordPress:Pages|网页]],这个网页是用[[WordPress:Administration_Panels#Write_Page|写]] > [[WordPress:Write_Page_SubPanel|网页]]管理面板创建的。你可以通过将<var>title_li</var>参数设置为一个空字符串,可以移除最外面的item(<tt>li.pagenav</tt>)并且列出(<tt>ul</tt>)。
 
All list items (<tt>li</tt>) generated by '''wp_list_pages()''' are marked with the class <tt>page_item</tt>. When '''wp_list_pages()''' is called while displaying a Page, the list item for that Page is given the additional class <tt>current_page_item</tt>.
 
'''wp_列表_网页()'''产生的所有的列表items(<tt>li</tt>)都标记了class <tt>page_item</tt>。当显示网页的时候,调用了'''wp_list_pages()''',关于那个网页的列表item会得到额外的class<tt>当前_网页_item</tt>。
 
<pre>
<li class="pagenav">
  Pages
  <ul>
    <li class="page_item current_page_parent">
      [parent of the current page]
      <ul>
        <li class="page_item current_page_item">
          [the current page]
        </li>
      </ul>
    </li>
    <li class="page_item">
      [another page]
    </li>
  </ul>
</li>
</pre>
 


<pre>
<pre>
第238行: 第516行:


They can be styled with [[WordPress:Glossary#CSS|CSS selectors]]:
They can be styled with [[WordPress:Glossary#CSS|CSS selectors]]:
这些可以用[[WordPress:Glossary#CSS|CSS 选择器]]设计:
  .pagenav { ... }
  .page_item { ... }
  .current_page_item { ... }
  .current_page_parent { ... }


   .pagenav { ... }
   .pagenav { ... }
第245行: 第528行:


== Parameters ==
== Parameters ==
== 参数==
; '''sort_column''' (''string''):Sorts the list of Pages in a number of different ways. The default setting is ''sort alphabetically by Page title''.
; '''sort_column''' (''string''):Sorts the list of Pages in a number of different ways. The default setting is ''sort alphabetically by Page title''.


:* <tt>'post_title'</tt> - Sort Pages alphabetically (by title) - default
; '''分类_column''' (''string''):以许多不同的方式给列出的网页分类。默认设置为''根据网页标题的字母顺序分类''。
 
:* <tt>'post_title'</tt> - Sort Pages alphabetically (by title) – default
 
:* <tt>'文章_标题'</tt> -(根据标题)将网页按照字母顺序分类-默认
 
:* <tt>'menu_order'</tt> - Sort Pages by Page Order. ''N.B.'' Note the difference between ''Page Order'' and ''Page ID''. The Page ID is a unique number assigned by WordPress to every post or page. The Page Order can be set by the user in the [[WordPress:Write_Page_SubPanel|Write>Pages]] administrative panel. See the [[WordPress:#List Pages by Page Order|example]] below.
:* <tt>'menu_order'</tt> - Sort Pages by Page Order. ''N.B.'' Note the difference between ''Page Order'' and ''Page ID''. The Page ID is a unique number assigned by WordPress to every post or page. The Page Order can be set by the user in the [[WordPress:Write_Page_SubPanel|Write>Pages]] administrative panel. See the [[WordPress:#List Pages by Page Order|example]] below.
:* <tt>'menu_顺序'</tt> -根据网页顺序给网页分类。''N.B.'' 注意''网页顺序'' 和''网页 ID''之间的区别。网页ID是一个独特的数字,是由WordPress指定给每篇文章或者每个网页的。用户可以在[[WordPress:Write_Page_SubPanel|写>网页]]管理面板上设置网页顺序。请看看下面的[[WordPress:#List Pages by Page Order|例子]]。
:* <tt>'post_date'</tt> - Sort by creation time.
:* <tt>'post_date'</tt> - Sort by creation time.
:* <tt>'post_modified'</tt> - Sort by time last modified.
:* <tt>'post_modified'</tt> - Sort by time last modified.
第255行: 第547行:
:* <tt>'post_name'</tt> - Sort alphabetically by Post [[WordPress:Glossary#Slug|slug]].
:* <tt>'post_name'</tt> - Sort alphabetically by Post [[WordPress:Glossary#Slug|slug]].
----
----
:* <tt>'文章_日期'</tt> - 根据创建时间分类。
:* <tt>'更改的_文章'</tt> - 根据最后一次更改分类。
:* <tt>'ID'</tt> - 根据网页ID分类。
:* <tt>'文章_作者'</tt> - 根据网页作者的 ID分类。
:* <tt>'文章_名称'</tt> - 根据文章的[[WordPress:Glossary#Slug|slug]],按字母顺序分类。
----
'''Note:''' The '''sort_column''' parameter can be used to sort the list of Pages by the descriptor of any field in the [[WordPress:Database Description#Table:_wp_posts|wp_post table]] of the WordPress database. Some useful examples are listed here.  
'''Note:''' The '''sort_column''' parameter can be used to sort the list of Pages by the descriptor of any field in the [[WordPress:Database Description#Table:_wp_posts|wp_post table]] of the WordPress database. Some useful examples are listed here.  
----
'''注:''' '''sort_column'''参数可以用来给列出的网页分类,根据WordPress数据库的[[WordPress:Database Description#Table:_wp_posts|wp_文章 表格]]的任何栏中的描述符来给文章分类。这里列出了一些有用的例子。
----
----


; '''sort_order''' (''string''):Change the sort order of the list of Pages (either ascending or descending). The default is ''ascending''. Valid values:
; '''sort_order''' (''string''):Change the sort order of the list of Pages (either ascending or descending). The default is ''ascending''. Valid values:
; '''分类_顺序''' (''string''):更改列出的网页的分类顺序(升序的或者降序的)。默认为''升序的'',有效的参数值:
:* <tt>'asc'</tt> - Sort from lowest to highest (Default).
:* <tt>'asc'</tt> - Sort from lowest to highest (Default).
:* <tt>'desc'</tt> - Sort from highest to lowest.
:* <tt>'desc'</tt> - Sort from highest to lowest.
:* <tt>'asc'</tt> -从最低到最高分类 (默认)。.
:* <tt>'desc'</tt> - 从最高到最低分类。


; '''exclude''' (''string''):Define a comma-separated list of Page IDs to be excluded from the list (example: <tt>'exclude=3,7,31'</tt>). There is no default value. See the [[WordPress:#Exclude Pages from List|Exclude Pages from List]] example below.
; '''exclude''' (''string''):Define a comma-separated list of Page IDs to be excluded from the list (example: <tt>'exclude=3,7,31'</tt>). There is no default value. See the [[WordPress:#Exclude Pages from List|Exclude Pages from List]] example below.
; '''删除''' (''string''):默认用逗号将需要从列表上删除的网页的ID分开(例如:<tt>'删除=3,7,31'</tt>)。没有默认参数值。请看看下面的例子[[WordPress:#Exclude Pages from List|从列表中删除网页]]。


; '''include''' (''string''):Only include certain Pages in the list generated by ''wp_list_pages''. Like '''exclude''', this parameter takes a comma-separated list of Page IDs. There is no default value. See the [[WordPress:#Include Pages in List|Include Pages in List]] example below.
; '''include''' (''string''):Only include certain Pages in the list generated by ''wp_list_pages''. Like '''exclude''', this parameter takes a comma-separated list of Page IDs. There is no default value. See the [[WordPress:#Include Pages in List|Include Pages in List]] example below.
; '''包含''' (''string''):在''wp_列表_网页''产生的列表上只包含特别的网页。像'''删除''',这个参数拥有一个用逗号分开的网页ID列表。没有默认参数值。请看看[[WordPress:#Include Pages in List|在一个列表中包含网页]]下面的例子。


; '''depth''' (''integer''):This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by ''wp_list_pages''. The default value is ''0'' (display all pages, including all sub-pages).
; '''depth''' (''integer''):This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by ''wp_list_pages''. The default value is ''0'' (display all pages, including all sub-pages).
; '''层级''' (''整数''):这个参数控制了''wp_列表_网页''产生的列表中可以包含多少层级的网页。默认值为''0''(显示所有的网页,包括子网页)。
:* <tt>0</tt>  - Pages and sub-pages displayed in hierarchical (indented) form (Default).
:* <tt>0</tt>  - Pages and sub-pages displayed in hierarchical (indented) form (Default).
:* <tt>0</tt>  -以层级(嵌套)方式(默认)显示的网页和子网页。
:* <tt>-1</tt> - Pages in sub-pages displayed in flat (no indent) form.
:* <tt>-1</tt> - Pages in sub-pages displayed in flat (no indent) form.
:* <tt>-1</tt> -子网页中的网页以flat(非嵌套)的方式显示。
:* <tt>1</tt>  - Show only top level Pages
:* <tt>1</tt>  - Show only top level Pages
:* <tt>1</tt>  -只显示最高级别的网页
:* <tt>2</tt>  - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.
:* <tt>2</tt>  - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.
:* <tt>2</tt>  -值为2(或者更高)规定了显示网页时,可以下降的层次(或者层级)。
   
   
; '''child_of''' (''integer''):Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to ''0'' (displays all Pages).
; '''child_of''' (''integer''):Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to ''0'' (displays all Pages).
; '''child_of''' (''整数''):只显示一个单独网页的子网页;为一个网页使用ID作为参数值。默认为''0''(显示所有网页)。


; '''show_date''' (''string''):Display creation or last modified date next to each Page. The default value is the ''null value'' (do not display dates). Valid values:
; '''show_date''' (''string''):Display creation or last modified date next to each Page. The default value is the ''null value'' (do not display dates). Valid values:
; '''显示_日期'''(''string''):在每个网页的旁边显示创建或者最后更改的日期。默认值为''零''(不显示日期)。有效的参数值:
:* <tt>'<nowiki></nowiki>'</tt> - Display no date (Default).
:* <tt>'<nowiki></nowiki>'</tt> - Display no date (Default).
:* <tt>'<nowiki></nowiki>'</tt> -不显示日期(默认)。
:* <tt>'modified'</tt> - Display the date last modified.
:* <tt>'modified'</tt> - Display the date last modified.
:* <tt>'更改的'</tt> -显示最后更改的日期。
:* <tt>'xxx'</tt> - Any value other than ''modified'' displays the date ('''post_date''') the Page was first created. See the [[WordPress:#Sort Pages by Post Date|example]] below.
:* <tt>'xxx'</tt> - Any value other than ''modified'' displays the date ('''post_date''') the Page was first created. See the [[WordPress:#Sort Pages by Post Date|example]] below.
:* <tt>'xxx'</tt> -除了''modified''的任何参数值显示了网页首次创建时的日期('''文章_日期''')。请看看下面的[[WordPress:#Sort Pages by Post Date|例子]]。


; '''date_format''' (''string''):Controls the format of the Page date set by the '''show_date''' parameter (example: "<tt><nowiki>l, F j, Y</nowiki></tt>"). This parameter defaults to the date format configured in your WordPress options. See [[WordPress:Formatting Date and Time]] and the [http://php.net/date date format page on the php web site].
; '''date_format''' (''string''):Controls the format of the Page date set by the '''show_date''' parameter (example: "<tt><nowiki>l, F j, Y</nowiki></tt>"). This parameter defaults to the date format configured in your WordPress options. See [[WordPress:Formatting Date and Time]] and the [http://php.net/date date format page on the php web site].
; '''数据_格式''' (''string''):控制了'''显示_日期'''参数设置的网页日期格式(例如:"<tt><nowiki>l, F j, Y</nowiki></tt>")。这个参数默认日期格式为配置在WordPress上的选项。请看看[[WordPress:Formatting Date and Time|日期和时间格式]]和[http://php.net/date php 网站上的日期格式网页]


; '''title_li''' (''string''):Set the text and style of the Page list's heading. Defaults to <tt>'__('Pages')'</tt>, which displays "Pages" (the <tt>__(&#039;&#039;)</tt> is used for [[WordPress:Localization|localization purposes]]). If passed a null or empty value (<tt>&#039;&#039;</tt>), no heading is displayed, and the list will not be wrapped with <tt>&lt;ul>, &lt;/ul></tt> tags. See the example for [[WordPress:#Hiding or Changing the List Heading|Headings]].
; '''title_li''' (''string''):Set the text and style of the Page list's heading. Defaults to <tt>'__('Pages')'</tt>, which displays "Pages" (the <tt>__(&#039;&#039;)</tt> is used for [[WordPress:Localization|localization purposes]]). If passed a null or empty value (<tt>&#039;&#039;</tt>), no heading is displayed, and the list will not be wrapped with <tt>&lt;ul>, &lt;/ul></tt> tags. See the example for [[WordPress:#Hiding or Changing the List Heading|Headings]].
; '''title_li''' (''string''):设置网页列表的标头的文本和样式。默认为<tt>'__('网页')'</tt>,显示了"网页"(为[[WordPress:Localization|本地化目的]]使用<tt>__(&#039;&#039;)</tt>)。如果传递了一个零或者空的参数值,(<tt>&#039;&#039;</tt>),不显示任何标题,而且列表也不会外包上<tt>&lt;ul>, &lt;/ul></tt>标签。请看看关于[[WordPress:#Hiding or Changing the List Heading|标头]]的例子。


; '''echo''' (''boolean''):Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is ''1'' (display the generated list items). Valid values:
; '''echo''' (''boolean''):Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is ''1'' (display the generated list items). Valid values:
:* <tt>1 (true)</tt> - default
:* <tt>1 (true)</tt> - default
:* <tt>0 (false)</tt>
:* <tt>0 (false)</tt>
; '''echo''' (''boolean''):Toggles链接产生的列表的显示或者返回链接作为HTML文本字符串,用于PHP。默认值为''1''(显示产生的列表item)。有效的参数值:
:* <tt>1 (正确的)</tt> - 默认
:* <tt>0 (错误的)</tt>


; hierarchical : (''boolean'') Display sub-Pages in an indented manner below their parent or list the Pages inline.  The default is ''true'' (display sub-Pages indented below the parent list item). Valid values:
; hierarchical : (''boolean'') Display sub-Pages in an indented manner below their parent or list the Pages inline.  The default is ''true'' (display sub-Pages indented below the parent list item). Valid values:
;层级的:(''boolean'')在母网页下,以嵌套的方式显示子网页,或者列出网页inline。默认为''真的''(显示嵌套在母列表item下面的子网页)。有效的参数值:
:* <tt>1 (true)</tt> - default
:* <tt>1 (true)</tt> - default
:* <tt>0 (false)</tt>
:* <tt>0 (false)</tt>
:* <tt>1 (正确的)</tt> - 默认
:* <tt>0 (错误的)</tt>


; meta_key : (''string'') Only include the Pages that have this Custom Field Key (use in conjunction with the meta_value field).
; meta_key : (''string'') Only include the Pages that have this Custom Field Key (use in conjunction with the meta_value field).
; meta_key : (''string'')只包含拥有这个自定义Field Key的网页(和meta_value field用在一起)。
; meta_value : (''string'') Only include the Pages that have this Custom Field Value (use in conjuntion with the meta_key field).
; meta_value : (''string'') Only include the Pages that have this Custom Field Value (use in conjuntion with the meta_key field).
; meta_value : (''string'') 只包含拥有这个自定义Field Key参数值的网页(和meta_key field用在一起)。


== Related ==
== Related ==
第299行: 第658行:


{{Query String Tag Footer}}
{{Query String Tag Footer}}
{{Copyedit}}
== 相关的 ==
{{标签 总 标签}}
{{查询 字符串 标签 页底文字}}


{{Copyedit}}
{{Copyedit}}

2008年7月4日 (五) 17:02的版本

Description

描述

The Template Tag, wp_list_pages(), displays a list of WordPress WordPress:Pages as links. It is often used to customize the Sidebar or Header, but may be used in other WordPress:Templates as well.

模板标签,wp_list_网页(),显示了WordPres网页的一个列表,作为一列链接。wp_list_pages()通过用来自定义工具条或者 标头,但是也可能在其它的模板中使用。

This Template Tag is available for WordPress versions 1.5 and newer.

WordPress1.5版本以及更新的版本中拥有这个模板标签

Usage

%%% <?php wp_list_pages('arguments'); ?> %%%

用法

%%% <?php wp_列表_网页('参数'); ?> %%%

Examples

例子

Default Usage

默认用法

$defaults = array(
    'depth'       => 0, 
    'show_date'   => '',
    'date_format' => get_option('date_format'),
    'child_of'    => 0, 
    'exclude'     => '',
    'title_li'    => __('Pages'), 
    'echo'        => 1,
    'authors'     => '',
    'sort_column' => 'menu_order, post_title');
$defaults = array(
    '深度'       => 0, 
    '显示_日期'   => '',
    '日期_格式' => 得到_选项('日期_格式'),
    'child_of'    => 0, 
    '删除'     => '',
    'title_li'    => __('Pages'), 
    'echo'        => 1,
    '作者'     => '',
    'sort_column' => 'menu_order, post_title');

By default, the usage shows:

默认情况下,用法显示:

  • All Pages and sub-pages are displayed (no depth restriction)
  • 显示了所有的网页和子网页(没有层级限制)
  • Date created is not displayed
  • 不显示创建的日期
  • Is not restricted to the child_of any Page
  • 不限制到任何网页的子网页
  • No pages are excluded
  • 不删除任何网页
  • The title of the pages listed is "Pages"
  • 网页的标题列为"网页"
  • Results are echoed (displayed)
  • 结果得到反映(显示)
  • Is not restricted to any specific author
  • 文章不限制为某个作者的
  • Sorted by Page Order then Page Title.
  • 有网页顺序分类然后有网页标题分类。
  • Sorted in ascending order (not shown in defaults above)
  • 以升序分类(不在上面的默认设置中显示)
  • Pages displayed in a hierarchical indented fashion (not shown in defaults above)
  • 网页以层级嵌套的方式显示(不在上面的默认设置中显示)
  • Includes all Pages (not shown in defaults above)
  • 包含所有的网页(不在上面的默认设置中显示)
  • Not restricted to Pages with specific meta key/meta value (not shown in defaults above)
  • 不限制为拥有特别的meta key/meta参数值的网页(不显示在上述的默认设置中)
wp_list_pages();

wp_列表_网页();

Hiding or Changing the List Heading

隐藏或者更改列表标头

The default heading of the list ("Pages") of Pages generated by wp_list_pages can be hidden by passing a null or empty value to the title_li parameter. The following example displays no heading text above the list.

wp_列表_网页产生的网页("网页")列表的默认标题,可以通过向title_li 参数传递一个零或者空参数值,得到隐藏。下面的例子显示了列表上方没有标题文本。

<ul>
<?php
wp_list_pages('title_li='); ?>
</ul>


<ul>
<?php
wp_列表_网页('title_li='); ?>
</ul>

In the following example, only Pages with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word "Poetry", with a heading style of <h2>:

在下面的例子中,只有ID是9,5,23的网页包含在列表中而且标题文本被更改为"诗",标头形式为<h2>:

<ul>
<?php
wp_list_pages('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?>
</ul>

<ul>
<?php
wp_list_pages('包含=5,9,23&title_li=<h2>' . __('诗') . '</h2>' ); ?>
</ul>

List Pages by Page Order

根据网页顺序列出网页

The following example lists the Pages in the order defined by the Page Order settings for each Page in the Write > Page administrative panel.

下面的例子,根据 > 网页 管理面板中设置的每个网页的排序来列出网页。

<ul>
<?php
wp_list_pages('sort_column=menu_order'); ?>
</ul>

<ul>
<?php
wp_list_pages('sort_column=menu_order'); ?>
</ul>

If you wanted to sort the list by Page Order and display the word "Prose" as the list heading (in h2 style) on a Sidebar, you could add the following code to the sidebar.php file:

如果你想要根据网页顺序给列表分类,而且在工具条上显示"散文"作为列表标题(以h2样式),你可以添加以下的代码到sidebar.php文件上:

<ul>
<?php
wp_list_pages('sort_column=menu_order&title_li=<h2>' . __('Prose') . '</h2>' ); ?>
</ul>


<ul>
<?php
wp_list_pages('sort_column=menu_order&title_li=<h2>' . __('Prose') . '</h2>' ); ?>
</ul>

Using the following piece of code, the Pages will display without heading and in Page Order:

使用下面的这些代码,网页会以网页顺序显示,而且还没有标题:

<ul>
<?php
wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>


<ul>
<?php
wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>

Sort Pages by Post Date

根据文章日期给网页分类

This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.

这个例子显示了网页根据(创建)日期分类,而且在每个网页列表item的旁边显示了日期。

<ul>
<?php
wp_list_pages('sort_column=post_date&show_date=created'); ?>
</ul>

<ul>
<?php
wp_list_pages('sort_column=post_date&show_date=created'); ?>
</ul>

Exclude Pages from List

从列表中删除网页

Use the exclude parameter hide certain Pages from the list to be generated by wp_list_pages.

使用删除参数隐藏wp_list_pages产生的列表中的某个网页。

<ul>
<?php
wp_list_pages('exclude=17,38' ); ?>
</ul>

<ul>
<?php
wp_list_pages('exclude=17,38' ); ?>
</ul>

Include Pages in List

在列表中包含网页

To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the include parameter. 在一个列表中只包含某个特别的网页,例如,ID数字为35,7,26和13的网页,使用包含参数。

<ul>
<?php
wp_list_pages('include=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?>
</ul>

<ul>
<?php
wp_list_pages('包含=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?>
</ul>

List Sub-Pages (versions prior to Wordpress 2.0.1)

列出子网页(Wordpress 2.0.1之前的版本)

Put this inside the the_post() section of the page.php template of your WordPress theme after the_content(), or put it in a copy of the page.php template that you use for pages that have sub-pages:

将这个放到the_内容()后的WordPress主题的page.php 模板的the_文章()部分的内部,或者将这个放到page.php模板的一个拷贝中,你为拥有子网页的网页使用这个page.php模板:

<ul>
<?php
global $id; // teensy bit insane, sorry
$date_format = '<\b\r /><\s\p\a\n '. '\s\t\y\l\e="\f\o\n\t-\s\i\z\e: \s\m\a\l\l\e\r">'. '\l\a\s\t\m\o\d Y-n-j</\s\p\a\n>'; wp_list_pages("title_li=&child_of=$id&show_date=modified
&date_format=$date_format"); ?>
</ul>


<ul>
<?php
global $id; // teensy bit insane, sorry
$date_format = '<\b\r /><\s\p\a\n '. '\s\t\y\l\e="\f\o\n\t-\s\i\z\e: \s\m\a\l\l\e\r">'. '\l\a\s\t\m\o\d Y-n-j</\s\p\a\n>'; wp_list_pages("title_li=&child_of=$id&show_date=modified
&date_format=$date_format"); ?>
</ul>

NOTE: This example does not work with Wordpress 2.0.1 or newer if placed in a page template because the global $id is not set. Use the following code

注:如果这个例子放到了一个网页模板中,在WordPress2.0.1或者更新的版本中不能够运行,因为没有设置全局$id。使用下面的代码

List Sub-Pages (Wordpress 2.0.1 or newer)

列出子网页 (Wordpress 2.0.1 或者更新的版本)

NOTE: Requires an HTML tag (either <ul> or <ol>) even if there are no subpages. Keep this in mind if you are using css to style the list.

注意:即使没有子网页,也需要一个HTML标签(<ul> 或者<ol>)。当你使用css设计列表的时候,要牢记这一点。

<ul>
<?php
wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified
&date_format=$date_format'); ?>
</ul>


<ul>
<?php
wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified
&date_format=$date_format'); ?>
</ul>

The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:

只有当前的网页拥有子网页的时候,下面的例子才会产生一个列表(子网页是指定当前网页为母网页的网页):

<?php
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>

<?php
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>

List subpages even if on a subpage

即使没有子网页,也列出子网页

The above examples will only show the children from the parent page, but not when actually on a child page. This code will show the child pages, and only the child pages, when on a parent or on one of the children.

上述的例子指示显示了来自于母网页的子网页,但是并不是真正地在一个子网页上,这个代码会显示子网页,而且只有子网页在母网页上或者在其中的一个子网页上时,参会显示。

    • warning ** This code will not work if placed after a widget block in the sidebar.


    • 警醒 ** 如果将这个代码放到一个工具条上的一个widget 块上时,这个代码就不会运行。

<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>


<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>

Markup and styling of page items

网页items的标记和样式

By default, wp_list_pages() generates a nested, unordered list of WordPress WordPress:Pages created with the Write > Page admin panel. You can remove the outermost item (li.pagenav) and list (ul) by setting the title_li parameter to an empty string.

默认情况下,wp_列表_网页()产生一个无序的,嵌套的WordPress网页,这个网页是用 > 网页管理面板创建的。你可以通过将title_li参数设置为一个空字符串,可以移除最外面的item(li.pagenav)并且列出(ul)。

All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying a Page, the list item for that Page is given the additional class current_page_item.

wp_列表_网页()产生的所有的列表items(li)都标记了class page_item。当显示网页的时候,调用了wp_list_pages(),关于那个网页的列表item会得到额外的class当前_网页_item

<li class="pagenav">
  Pages
  <ul>
    <li class="page_item current_page_parent">
      [parent of the current page]
      <ul>
        <li class="page_item current_page_item">
          [the current page]
        </li>
      </ul>
    </li>
    <li class="page_item">
      [another page]
    </li>
  </ul>
</li>


<li class="pagenav">
  Pages
  <ul>
    <li class="page_item current_page_parent">
      [parent of the current page]
      <ul>
        <li class="page_item current_page_item">
          [the current page]
        </li>
      </ul>
    </li>
    <li class="page_item">
      [another page]
    </li>
  </ul>
</li>

They can be styled with CSS selectors: 这些可以用CSS 选择器设计:

 .pagenav { ... }
 .page_item { ... }
 .current_page_item { ... }
 .current_page_parent { ... }
 .pagenav { ... }
 .page_item { ... }
 .current_page_item { ... }
 .current_page_parent { ... }

Parameters

参数

sort_column (string)
Sorts the list of Pages in a number of different ways. The default setting is sort alphabetically by Page title.
分类_column (string)
以许多不同的方式给列出的网页分类。默认设置为根据网页标题的字母顺序分类
  • 'post_title' - Sort Pages alphabetically (by title) – default
  • '文章_标题' -(根据标题)将网页按照字母顺序分类-默认
  • 'menu_order' - Sort Pages by Page Order. N.B. Note the difference between Page Order and Page ID. The Page ID is a unique number assigned by WordPress to every post or page. The Page Order can be set by the user in the Write>Pages administrative panel. See the [[WordPress:#List Pages by Page Order|example]] below.
  • 'menu_顺序' -根据网页顺序给网页分类。N.B. 注意网页顺序网页 ID之间的区别。网页ID是一个独特的数字,是由WordPress指定给每篇文章或者每个网页的。用户可以在写>网页管理面板上设置网页顺序。请看看下面的[[WordPress:#List Pages by Page Order|例子]]。
  • 'post_date' - Sort by creation time.
  • 'post_modified' - Sort by time last modified.
  • 'ID' - Sort by numeric Page ID.
  • 'post_author' - Sort by the Page author's numeric ID.
  • 'post_name' - Sort alphabetically by Post slug.

  • '文章_日期' - 根据创建时间分类。
  • '更改的_文章' - 根据最后一次更改分类。
  • 'ID' - 根据网页ID分类。
  • '文章_作者' - 根据网页作者的 ID分类。
  • '文章_名称' - 根据文章的slug,按字母顺序分类。

Note: The sort_column parameter can be used to sort the list of Pages by the descriptor of any field in the wp_post table of the WordPress database. Some useful examples are listed here.


注: sort_column参数可以用来给列出的网页分类,根据WordPress数据库的wp_文章 表格的任何栏中的描述符来给文章分类。这里列出了一些有用的例子。


sort_order (string)
Change the sort order of the list of Pages (either ascending or descending). The default is ascending. Valid values:
分类_顺序 (string)
更改列出的网页的分类顺序(升序的或者降序的)。默认为升序的,有效的参数值:
  • 'asc' - Sort from lowest to highest (Default).
  • 'desc' - Sort from highest to lowest.
  • 'asc' -从最低到最高分类 (默认)。.
  • 'desc' - 从最高到最低分类。
exclude (string)
Define a comma-separated list of Page IDs to be excluded from the list (example: 'exclude=3,7,31'). There is no default value. See the [[WordPress:#Exclude Pages from List|Exclude Pages from List]] example below.
删除 (string)
默认用逗号将需要从列表上删除的网页的ID分开(例如:'删除=3,7,31')。没有默认参数值。请看看下面的例子[[WordPress:#Exclude Pages from List|从列表中删除网页]]。
include (string)
Only include certain Pages in the list generated by wp_list_pages. Like exclude, this parameter takes a comma-separated list of Page IDs. There is no default value. See the [[WordPress:#Include Pages in List|Include Pages in List]] example below.
包含 (string)
wp_列表_网页产生的列表上只包含特别的网页。像删除,这个参数拥有一个用逗号分开的网页ID列表。没有默认参数值。请看看[[WordPress:#Include Pages in List|在一个列表中包含网页]]下面的例子。
depth (integer)
This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by wp_list_pages. The default value is 0 (display all pages, including all sub-pages).
层级 (整数)
这个参数控制了wp_列表_网页产生的列表中可以包含多少层级的网页。默认值为0(显示所有的网页,包括子网页)。
  • 0 - Pages and sub-pages displayed in hierarchical (indented) form (Default).
  • 0 -以层级(嵌套)方式(默认)显示的网页和子网页。
  • -1 - Pages in sub-pages displayed in flat (no indent) form.
  • -1 -子网页中的网页以flat(非嵌套)的方式显示。
  • 1 - Show only top level Pages
  • 1 -只显示最高级别的网页
  • 2 - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.
  • 2 -值为2(或者更高)规定了显示网页时,可以下降的层次(或者层级)。
child_of (integer)
Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to 0 (displays all Pages).
child_of (整数)
只显示一个单独网页的子网页;为一个网页使用ID作为参数值。默认为0(显示所有网页)。
show_date (string)
Display creation or last modified date next to each Page. The default value is the null value (do not display dates). Valid values:
显示_日期(string)
在每个网页的旁边显示创建或者最后更改的日期。默认值为(不显示日期)。有效的参数值:
  • '' - Display no date (Default).
  • '' -不显示日期(默认)。
  • 'modified' - Display the date last modified.
  • '更改的' -显示最后更改的日期。
  • 'xxx' - Any value other than modified displays the date (post_date) the Page was first created. See the [[WordPress:#Sort Pages by Post Date|example]] below.
  • 'xxx' -除了modified的任何参数值显示了网页首次创建时的日期(文章_日期)。请看看下面的[[WordPress:#Sort Pages by Post Date|例子]]。
date_format (string)
Controls the format of the Page date set by the show_date parameter (example: "l, F j, Y"). This parameter defaults to the date format configured in your WordPress options. See WordPress:Formatting Date and Time and the date format page on the php web site.
数据_格式 (string):控制了显示_日期参数设置的网页日期格式(例如:"l, F j, Y")。这个参数默认日期格式为配置在WordPress上的选项。请看看日期和时间格式php 网站上的日期格式网页
title_li (string)
Set the text and style of the Page list's heading. Defaults to '__('Pages')', which displays "Pages" (the __('') is used for localization purposes). If passed a null or empty value (''), no heading is displayed, and the list will not be wrapped with <ul>, </ul> tags. See the example for [[WordPress:#Hiding or Changing the List Heading|Headings]].
title_li (string)
设置网页列表的标头的文本和样式。默认为'__('网页')',显示了"网页"(为本地化目的使用__(''))。如果传递了一个零或者空的参数值,(''),不显示任何标题,而且列表也不会外包上<ul>, </ul>标签。请看看关于[[WordPress:#Hiding or Changing the List Heading|标头]]的例子。
echo (boolean)
Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 1 (display the generated list items). Valid values:
  • 1 (true) - default
  • 0 (false)
echo (boolean)
Toggles链接产生的列表的显示或者返回链接作为HTML文本字符串,用于PHP。默认值为1(显示产生的列表item)。有效的参数值:
  • 1 (正确的) - 默认
  • 0 (错误的)
hierarchical
(boolean) Display sub-Pages in an indented manner below their parent or list the Pages inline. The default is true (display sub-Pages indented below the parent list item). Valid values:

;层级的:(boolean)在母网页下,以嵌套的方式显示子网页,或者列出网页inline。默认为真的(显示嵌套在母列表item下面的子网页)。有效的参数值:

  • 1 (true) - default
  • 0 (false)
  • 1 (正确的) - 默认
  • 0 (错误的)
meta_key
(string) Only include the Pages that have this Custom Field Key (use in conjunction with the meta_value field).
meta_key
(string)只包含拥有这个自定义Field Key的网页(和meta_value field用在一起)。
meta_value
(string) Only include the Pages that have this Custom Field Value (use in conjuntion with the meta_key field).
meta_value
(string) 只包含拥有这个自定义Field Key参数值的网页(和meta_key field用在一起)。

Related

模板:Tag General Tags

模板:Query String Tag Footer

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.


相关的

模板:标签 总 标签

模板:查询 字符串 标签 页底文字

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.