MENU

wp_nav_menu

ナビゲーションメニューを表示します。メニューはバックエンド:外観>メニューから作成する事ができます。

Display a navigation menu. Menus can be created from the backend: Appearance > Menus.

Given a theme_location parameter, the function displays the menu assigned to that location, or nothing if no such location exists or no menu is assigned to it.

If not given a theme_location parameter, the function displays

  • the menu matching the ID, slug, or name given by the menu parameter, if that menu has at least 1 item;
  • otherwise, the first non-empty menu;
  • otherwise, output of the function given by the fallback_cb parameter (wp_page_menu(), by default);
  • otherwise nothing.
目次

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

[php] [/php]

デフォルトの使い方

[php] ,
‘menu’ => ,
‘container’ => ‘div’,
‘container_class’ => ‘menu-{menu slug}-container’,
‘container_id’ => ,
‘menu_class’ => ‘menu’,
‘menu_id’ => ,
‘echo’ => true,
‘fallback_cb’ => ‘wp_page_menu’,
‘before’ => ,
‘after’ => ,
‘link_before’ => ,
‘link_after’ => ,
‘items_wrap’ => ‘

    %3$s

‘,
‘depth’ => 0,
‘walker’ => );
?>[/php]

wp_nav_menuのパラメーター

$theme_locaton

(string) (optional) テーマ内のロケーションで使用されます。–ユーザーによって選択可能にするために、 register_nav_menu()で登録する必要があります。

(string) (optional) the location in the theme to be used–must be registered with register_nav_menu() in order to be selectable by the user

Default: None

$menu

(string) (optional) メニューは望まれていました;id、スラッグ、名前に対応します(順番に一致している)。

(string) (optional) The menu that is desired; accepts (matching in order) id, slug, name

Default: None

$container

(string) (optional) ulで囲むかどうか、何でそれを囲むか。

(string) (optional) Whether to wrap the ul, and what to wrap it with

Default: div

$container_class

(string) (optional)コンテナに適用されるクラスです。

(string) (optional) the class that is applied to the container

Default: menu-{menu slug}-container

$container_id

(string) (optional) コンテナに適用されるIDです。

(string) (optional) The ID that is applied to the container

Default: None

$menu_class

(string) (optional) CSSクラスは、メニューを形成するul要素に使用します。

(string) (optional) CSS class to use for the ul element which forms the menu

Default: menu

$menu_id

(string) (optional) メニューを形成するUL要素に適用されているIDです。

(string) (optional) The ID that is applied to the ul element which forms the menu

Default: menu slug, incremented

$echo

(boolean) (optional) メニューをエコーするか返すかどうかです。

(boolean) (optional) Whether to echo the menu or return it

Default: true

$fallback_cb

(string) (optional) メニューが存在しない場合は、コールバック関数を使用します。

(string) (optional) If the menu doesn’t exists, the callback function to use

Default: wp_page_menu

$before

(string) (optional) リンクテキストの前にテキストを出力します。

(string) (optional) Output text before the link text

Default: None

$after

(string) (optional) リンクテキストの後にテキストを出力します。

(string) (optional) Output text after the link text

Default: None

$link_before

(string) (optional) リンク前にテキストを出力します。

(string) (optional) Output text before the link

Default: None

$link_after

(string) (optional) リンク後にテキストを出力します。

(string) (optional) Output text after the link

Default: None

$items_wrap

(string) (optional) Whatever to wrap the items with an ul, and how to wrap them with

Default: None

$depth

(integer) (optional) いくつ階層のレベルは、含まれているか。0は全てを意味してます。

(integer) (optional) how many levels of the hierarchy are to be included where 0 means all

Default: 0

$walker

(string) (optional) カスタムウォーカーを使用します。

(string) (optional) Custom walker to use

Default: None

デフォルトの例

[php]
[/php]

特定のメニューをターゲット

[php] ‘Project Nav’ )); ?>[/php]

Twenty Tenテーマでの使用方法

[php]
目次