Amazon.co.jp ウィジェット

wp_list_pages – WordPress テンプレートタグのリファレンス

wp_list_pages()は、リンクとしてWordPressページのリストを表示します。 それは、SidebarかHeaderをカスタム設計するのにしばしば使用されますが、また、他のTemplatesで使用されるかもしれません。

このTemplate TagはWordPressバージョン1.5に利用可能であって、より新しいです。

原文(翻訳元):⇒Displays a list of WordPress Pages as links. It is often used to customize the Sidebar or Header, but may be used in other Templates as well.

wp_list_pagesのテンプレートタグ使用方法

<?php wp_list_pages( $args ); ?> 

デフォルトの使い方

 <?php $args = array(
    'depth'        => 0,
    'show_date'    => ,
    'date_format'  => get_option('date_format'),
    'child_of'     => 0,
    'exclude'      => ,
    'include'      => ,
    'title_li'     => __('Pages'),
    'echo'         => 1,
    'authors'      => ,
    'sort_column'  => 'menu_order, post_title',
    'link_before'  => ,
    'link_after'   => ,
    'exclude_tree' =>  ); ?> 

デフォルトでは、使用を示します:

原文(翻訳元):⇒By default, the usage shows:

  • すべてのページとサブページを表示します(深さ制限がありません)。
  • 作成された日付を表示しません。
  • どんなページの子供_にも制限されません。
  • ページは全く除かれません。
  • 記載されているのが、「ページ」であるというページのタイトル
  • 結果は反響されます(表示します)。
  • どんな特定の作者にも制限されません。
  • ページのOrderの当時のページTitleによって分類されます。
  • 昇順に(上のデフォルトで、目立たない)分類されます。
  • 階層的な入り込まれたファッション(上のデフォルトで、目立たない)で表示されたページ
  • すべてのページ(上のデフォルトで、目立たない)を含んでいます。
  • 特定のメタキー/メタ値でページに制限されません。(示されない上のデフォルトで)です。

原文(翻訳元):⇒ * 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
* No pages are explicitly included
* 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)
* No Parent/Child trees excluded

wp_list_pagesのパラメーター

sort_column

多くの異なった方法でページのリストを分類します。 アルファベット順に、既定の設定はページタイトルによる種類です。

原文(翻訳元)(string) Sorts the list of Pages in a number of different ways. The default setting is sort alphabetically by Page title.

  • ‘post_title’窶塔Aルファベット順に(タイトルで)、ページを分類してください窶塔fフォルトとします。
  • ‘menu_order’窶塔yージオーダーによる種類のページ。 N. B. ページOrderとページIDの違いに注意します。 Page IDはWordPressによってあらゆるポストかページに割り当てられたユニークな数です。 ページOrderはWrite>ページの管理のユーザでパネルを設定することであるかもしれません。 以下の例を見ます。
  • ‘post_date’窶淘n造時間までに種類。
  • ‘post_modified’窶桃ナ後に変更された時間までに種類。
  • ‘ID’窶盗白lPage IDのそばの種類。
  • ‘post_author’窶塔yージ作者の数値IDのそばの種類。
  • ‘post_name’窶塔Aルファベット順に、ポストスラグで、分類します。

原文(翻訳元) * ‘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 example below.
* ‘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.

注意: WordPressデータベースのwp_postテーブルのどんな分野に関する記述子でもページのリストを分類するのに種類_コラムパラメタを使用することができます。 いくつかの有用な例がここにリストアップされています。

原文(翻訳元)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_order

(string) ページ(昇るか、または下る)のリストの種類の注文を変えてください。 デフォルトは昇っています。 有効値:

原文(翻訳元)(string) Change the sort order of the list of Pages (either ascending or descending). The default is ascending. Valid values:

  • ‘asc’窶桃ナも低いのから最も高くなるまでの種類(デフォルト)。
  • ‘desc’窶桃ナも高いのから最も低くなるまでの種類。

原文(翻訳元) * ‘ASC’ – Sort from lowest to highest (Default).
* ‘DESC’ – Sort from highest to lowest.

exclude

ページIDのコンマで切り離されたリストを定義して、リスト(例: ‘3、7、31を除く’)から除かれてください。 デフォルト値が全くありません。 以下のListの例から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 Exclude Pages from List example below.

exclude_tree

原文(翻訳元)(string) Define a comma-separated list of parent Page IDs to be excluded. Use this parameter to exclude a parent and all of that parent’s child Pages. So ‘exclude_tree=5′ would exclude the parent Page 5, and its child (all descendant) Pages. (This parameter was added with Version 2.7, and it does not function as described as of version 2.8.1 – See bug report.)

include

(string)wp_list_pagesによって生成されたリストで単にあるページを含めてください。 同類が除く、このパラメタはページIDのコンマで切り離されたリストを取ります。 デフォルト値が全くありません。 以下の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 Include Pages in List example below.

depth

(integer)このパラメタは、wp_list_pagesによって発生したリストに含まれるようにページの階層構造のレベルがいくつであるか制御します。
デフォルト値は0(すべてのサブページを含んでいて、すべてのページ表示する)です。

原文(翻訳元)(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).

  • 0 窶塔yージと階層的な(入り込まれる)フォーム(デフォルト)に表示されたサブページ。
  • -1 窶燈ス坦な(インデントがない)フォームに表示されたサブページのページ。
  • 1窶塔gップ平らなページだけを見せます。
  • 2 窶・の値、(よりすばらしい)、ページを表示する際に下るために、深さ(または、レベル)を指定します。

原文(翻訳元) * 0 (default) Displays pages at any depth and arranges them hierarchically in nested lists
* -1 Displays pages at any depth and arranges them in a single, flat list
* 1 Displays top-level Pages only
* 2, 3 … Displays Pages to the given depth

child_of

(integer)1ページのサブページだけを表示します; ページに値としてIDを使用します。 0(すべてのページを表示する)へのデフォルト

原文(翻訳元)(integer) Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Note that the child_of parameter will also fetch “grandchildren” of the given ID, not just direct descendants. Defaults to 0 (displays all Pages).

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:

  • -日付(デフォルト)を全く表示しないでください。」
  • ‘modified’ 窶・最後に変更された日付を表示します。
  • ‘xxx’窶燈マ更された表示を除いて、いずれもページが最初に作成された日付(post_date)を評価します。 以下の例を見ます。

原文(翻訳元) * ” – 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 example below.

date_format

(string)show_dateのパラメタ(例: 「l、F j、Y」)からページ日付のセットの形式を制御します。 このパラメタはあなたのWordPressオプションで構成された日付の形式をデフォルトとします。 phpウェブサイトでFormatting Date、Time、および日付の形式ページを参照してください。

原文(翻訳元)(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 Formatting Date and Time and the date format page on the php web site.

title_li

(string)ページリストの見出しのテキストとスタイルを設定してください。 ‘__(‘Pages’)’へのデフォルト。(それは、”Pages”(the __()はローカライズ目的に使用される)を表示します)。 nullの、または、空の値の()を渡すなら、向かわないことを表示します、そして、<ul>, </ul>と共にリストを包装しないでしょう。 Headingsのための例を見てください。

原文(翻訳元)(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

    ,

tags. See the example for Headings.

echo

(boolean)トグル、HTMLテキストとしてのリストがPHPで使用されるために結ぶリンクかリターンの発生しているリストの表示。 デフォルト値は1(発生しているリスト項目を表示する)です。 有効値:

原文(翻訳元)(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)

meta_key

単にこのCustom Field Keyを持っているページを含めてください。(meta_value fieldに関連して、使用します)

原文(翻訳元)(string) Only include the Pages that have this Custom Field Key (use in conjunction with the meta_value field).

meta_value

単にこのCustom Field Value(meta_key fieldとconjuntionでは、使用する)を持っているPagesを含めてください。

原文(翻訳元)(string) Only include the Pages that have this Custom Field Value (use in conjunction with the meta_key field).

link_before

原文(翻訳元)(string) Sets the text or html that proceeds the link text inside tag. (This parameter was added with Version 2.7)

link_after

原文(翻訳元)(string) Sets the text or html that follows the link text inside tag. (This parameter was added with Version 2.7)

authors

原文(翻訳元)(string) Only include Pages authored by the authors in this comma-separated list of author IDs. If no authors are specified, all authors are included.

number

原文(翻訳元)(integer) Sets the number of Pages to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT. (This parameter was added with Version 2.8)

offset

原文(翻訳元)(integer) The number of Pages to pass over (or displace) before collecting the set of Pages. Default is no OFFSET. (This parameter was added with Version 2.8)

Hiding or Changing the List Heading

nullの、または、空の値をタイトル_liパラメタに通過することによって、wp_リスト_ページ生成されたページのリスト(「ページ」)に関するデフォルト見出しを隠すことができます。 以下の例はリストの上に見出しテキストを全く表示しません。

原文(翻訳元):⇒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.

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

以下の例では、ID9、5、および23がある唯一のページがリストで含められています、そして、見出しテキストは「詩」という言葉に変わりました、<h2>の見出しスタイルで:

原文(翻訳元):⇒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>:

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

List Pages by Page Order

オーダーにおけるページがWriteの各ページのためにページ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>

あなたがページOrderでリストを分類して、リスト見出しとしてSidebarに「散文」という言葉を表示したいなら(h2スタイルで)、以下のコードをsidebar.phpファイルに追加することができるでしょうに:

原文(翻訳元):⇒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:

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

以下のコードを使用して、ページは見出しなしでページOrderに表示するでしょう:

原文(翻訳元):⇒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>

Sort Pages by Post Date

この例は、(創造)日付で分類されたページを表示して、それぞれのページリスト項目の横で日付を示します。

原文(翻訳元):⇒This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.

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

Exclude Pages from List

使用、wp_list_pagesによって発生するようにリストにパラメタ獣皮確信しているパジェスを入れないようにしてください。 また、ページを除くと、優にサブページは、発生するようにリストに入れないようにされるでしょう。

原文(翻訳元):⇒Use the exclude parameter hide certain Pages from the list to be generated by wp_list_pages.

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

Include Pages in List

例えば、リストに、あるページだけを含むように、ID No.35があるページ(7、26、および13)は、インクルードパラメタを使用します。

原文(翻訳元):⇒To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the include parameter.

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

List Sub-Pages

Versions prior to WordPress 2.0.1 :

この内部を置いてください、_の後のあなたのWordPressテーマのpage.phpテンプレートの_ポスト()部は、()を満足させるか、またはあなたがサブページを持っているページに使用するpage.phpテンプレートのコピーにそれを入れます:

原文(翻訳元):⇒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:

<ul>
  <?php
  global $id;
  wp_list_pages("title_li=&child_of=$id&show_date=modified
  &date_format=$date_format"); ?>
</ul>

注意: または、この例がWordpressと共に働いていない、2.0、.1、 より新しいのですが、グローバルな$イドが設定されないので、ページテンプレートに置かれます。 以下のコードを使用してください。

原文(翻訳元):⇒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

WordPress 2.0.1 or newer :

注意: 「副-ページ」が全くなくても、HTMLタグ(<ul>か<ol>のどちらか)を必要とします。 リストを流行に合わせるのにcssを使用しているなら、これを覚えておいてください。

原文(翻訳元):⇒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.

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

現在のページのための子供(Parentとして現在のページを指定するページ)がいる場合にだけ、以下の例はリストを発生させるでしょう:

原文(翻訳元):⇒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 } ?>

List subpages even if on a subpage

上の例はいつではなく、実際に子供ページの親ページから子供を示すだけであるだろうか。 このコードは子供の親か1でオンな子供ページと、子供ページ、いつかだけを示すでしょう。

  • o サイドバーでのウィジェットブロックの後に置かれるならこのコードが扱わない警告**。

原文(翻訳元):⇒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.

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

<?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 } ?>

原文(翻訳元)As an alternative, this code in a sidebar.php, displays only top level Pages, but when viewing a Page that has children (or is a child) it displays only children of that parent.

* When visiting main page, all top level pages are listed in the sidebar.
* When visiting a top level page with no children, all top level pages are listed.
* When visiting a top level page with children, just the children pages, and descendant pages, are listed.
* When visiting a child page, just the children, and descendant pages, of that parent, are listed.

<?php
$output = wp_list_pages('echo=0&depth=1&title_li=<h2>Top Level Pages </h2>' );
if (is_page( )) {
  $page = $post->ID;
  if ($post->post_parent) {
    $page = $post->post_parent;
  }
  $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
  if ($children) {
    $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
  }
}
echo $output;
?>

原文(翻訳元)* Page List that: Only displays if child (sub) pages exist, displays page list of subpages on the parent page AND on the child pages HOWEVER this code keeps the parent page name in the title which makes it different from the previous example. (used for navigation on http://allianceitpro.com/)

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

  else {
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  $titlenamer = get_the_title($post->ID);
  }
  if ($children) { ?>

  <h2> <? echo $titlenamer ?> </h2>
  <ul>
  <?php echo $children; ?>
  </ul>

<?php } ?>

List whole subpages

原文(翻訳元)This is how to get the whole subpages list

<?php
if(!$post->post_parent){
	// will display the subpages of this top level page
	$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}else{
	// diplays only the subpages of parent level
	//$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");

	if($post->ancestors)
	{
		// now you can get the the top ID of this page
		// wp is putting the ids DESC, thats why the top level ID is the last one
		$ancestors = end($post->ancestors);
		$children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0");
		// you will always get the whole subpages list
	}
}

if ($children) { ?>
	<ul>
		<?php echo $children; ?>
	</ul>
<?php } ?>

Markup and styling of page items

デフォルトで、wp_list_pages()がWriteと共に作成されたWordPressページの入れ子にされて、順不同のリストを発生させる、> ページアドミンパネル。 あなたは、空のストリングにタイトル_liパラメタを設定することによって、一番はずれの商品(li.pagenav)とリスト(ul)を取り外すことができます。

wp_list_pages()によって発生したすべてのリスト項目(li)がクラスページ_項目でマークされます。 ページを表示している間wp_list_pages()を呼ぶとき、追加クラス現在の_のページ_品目をそのページのためのリスト項目に与えます。

原文(翻訳元):⇒By default, wp_list_pages() generates a nested, unordered list of 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.

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.

<li class="pagenav">
Pages [title_li]
  <ul>
    <!-- Output starts here if 'title_li' parameter is empty -->
    <li class="page-item-2 page_item current_page_ancestor current_page_parent">
      [parent of the current Page]
      <ul>
        <li class="page-item-21 page_item current_page_item">
          [the current Page]
        </li>
      </ul>
    </li>
    <li class="page-item-3 page_item">
      [another Page]
    </li>
  </ul>
</li>

CSSセレクタでそれらを流行に合わせることができます:

原文(翻訳元):⇒They can be styled with CSS selectors:

.pagenav { … } /* the outermost list item; contains whole list */
.page-item-2 { … } /* item for Page ID 2 */
.page_item { … } /* any Page item */
.current_page_item { … } /* the current Page */
.current_page_parent { … } /* parent of the current Page */
.current_page_ancestor { … } /* any ancestor of the current Page */

原文(翻訳元)In order to achieve an accordion menu effect for instance, the following CSS can be used:

.pagenav  ul ul,
.pagenav .current_page_item ul ul,
.pagenav .current_page_ancestor ul ul,
.pagenav .current_page_ancestor .current_page_item ul ul,
.pagenav .current_page_ancestor .current_page_ancestor ul ul {
	display: none;
	}

.pagenav .current_page_item ul,
.pagenav .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_ancestor ul {
	display: block;
	}

備考

原文(翻訳元) * See Also: wp_page_menu()

変更ログ

* Since: 1.5.0
* 2.7 : Added the link_before, link_after and exclude_tree parameters.
* 2.8 : Added the number and offset parameters.

ソースファイル

原文(翻訳元)wp_list_pages() is located in wp-includes/post-template.php.

関連テンプレートタグ

wp_list_authors, wp_list_categories, wp_list_pages, wp_list_bookmarks, wp_list_comments, wp_get_archives, wp_page_menu, wp_dropdown_pages, wp_dropdown_categories, wp_dropdown_users

Tags:

Page 1 of 11