wp_dropdown_pages

Sponsored Link

ボタンと共に選択ボックス(つまり、ドロップダウン)内にページリストを表示します。

Sponsored Link

Displays a list of pages in a select (i.e dropdown) box with no submit button.

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

<?php wp_dropdown_pages( $args ); ?> 

デフォルトの使い方

<?php $args = array(
    'depth'            => 0,
    'child_of'         => 0,
    'selected'         => 0,
    'echo'             => 1,
    'name'             => 'page_id',
    'show_option_none' => 
    'exclude'          => 
    'exclude_tree'     =>  ); ?>

デフォルトでの、使用を表示:

  • ページとサブページを階層(インデント)形式で表示
  • すべてのページを表示(子ページに制限されません)
  • ないページを’selected’またはディスプレイボックスで提示します。
  • 名前をドロップダウンボタンフォームに割り当てられる名前は、’page_id’です
  • あなたがNONEページを選択することを許可します(show_option_none)

By default, the usage shows:

* Pages and sub-pages displayed in hierarchical (indented) form
* Displays all pages (not restricted to child pages)
* No page is be ‘selected’ or presented in the display box
* The name assigned to the dropdown form is ‘page_id’
* Allows you to select NONE of the pages (show_option_none)

wp_dropdown_pagesのパラメーター

depth (integer)

このパラメーターは、ページの階層のどれくらいのレベルがwp_list_pagesによって生成するリストに含まれることになっているかについて制御します。デフォルト値は0です。

  • 0 – ページとサブページが階層(インデント)形式(デフォルト)で表示。
  • -1 – ページのサブページがフラット(インデントがない)形式で表示。
  • 1 – トップレベルのページのみ表示
  • 2 – 表示しているページに伝わる深さ(またはレベル)の値2(またはそれ以上)を指定します。

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 – Pages and sub-pages displayed in hierarchical (indented) form (Default).
* -1 – Pages in sub-pages displayed in flat (no indent) form.
* 1 – Show only top level Pages
* 2 – Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.

child_of (integer)

1つのページのみをサブページで表示する。;ページの値としてID を使用します。 デフォルトは0(すべてのページを表示)。

Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to 0 (displays all Pages).

selected

(integer)ページのページIDが表示ボックスに’selected’あるいは提示になります。デフォルトはページを選択されない。

(integer) Page ID of the page to be ‘selected’ or presented in the display box. Defaults to no page selected.

echo

(boolean)関連の生成するリストの表示を切り換えます。あるいは、PHPで使用されるHTMLテキストの文字列としてリストを返します。デフォルト値は1です(生成されたリストアイテムを表示します)。有効な値:

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)

name

(string)名前はドロップダウンフォームに割り当てられます。デフォルトは’page_id’

(string) Name assigned to the dropdown form. Defaults to ‘page_id’.

show_option_none

(string)ページのNONEを選ぶことができるために、dropdownにHTMLを引き起こします。

(string) Causes the HTML for the dropdown to allow you to select NONE of the pages.

exclude

(string)カテゴリIDのカンマで区切られたリストが除外されます。例えば、’exclude=4,12’の意味は、カテゴリIDが4と12は、表示/エコー或いは返しません。デフォルトは何も除外しません。

(string) Comma separated list of category IDs to exclude. For example, ‘exclude=4,12’ means category IDs 4 and 12 will NOT be displayed/echoed or returned. Defaults to exclude nothing.

exclude_tree

(string)親ページIDのカンマ区切りのリストを除外することを定義します。親と親の子ページ全てを除外する時、このパラメータを使用します。だから’exclude_tree=5’は、親ページ5とその子ページを除外します。このパラメーターは、バージョン2.7で利用できました。

(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 Pages. This parameter was available at Version 2.7.

他のパラメーター

それは可能ですが、確認されていません。get_pages関数のためのいくつかのパラメーターは、wp_dropdown_pagesでは使用する事ができません。ここに、get_pagesパラメーターのデフォルトの設定があります。

It is possible, but not confirmed, some of the paramters for the function get_pages could be used for wp_dropdown_pages. Here’s the default settings for the get_pages parameters

 <?php $args = array(
    'child_of'     => 0,
    'sort_order'   => 'ASC',
    'sort_column'  => 'post_title',
    'hierarchical' => 1,
    'exclude'      => ,
    'include'      => ,
    'meta_key'     => ,
    'meta_value'   => ,
    'authors'      => 
    'exclude_tree' => ); ?>

送信ボタンと共にドロップダウンを付ける方法

送信ボタンを持つHTML形式で階層のページのドロップダウンリストを表示します。

Displays a hierarchical page dropdown list in HTML form with a submit button.

<li id="pages">
 <h2><?php _e('pages:'); ?></h2>
   <form action="<?php bloginfo('url'); ?>" method="get">
   <?php wp_dropdown_pages(); ?>
   <input type="submit" name="submit" value="view" />
   </form>
</li>

変更ログ

Since 2.1.0

ソースファイル

wp_dropdown_pages()は、wp-includes/post-template.php内に位置しています。

wp_dropdown_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

Sponsored Link