この記事は2年以上前に書かれた記事です。現状にそぐわないかもなのでご注意を。

[WP] wp_list_pagesをショートコード化してくれるプラグイン

Page-list.

wp_list_pagesをページ内に埋め込みたいという要望はかなり多いはず。

ただそのたびに個別テンプレートを用意したり、条件分岐を設定するのも面倒。
気づいたらloop_page.phpがグチャグチャに…なんてことにも。

このプラグインを入れると、以下のショートコードが使えるようになるらしいです。
これから検証するのですが、ショートコードを忘れないようにメモメモφ(`д´)

  • [pagelist] 基本。wp_list_pages(‘title_li=’)
  • [subpages] 現在の子ページ。[pagelist child_of=”current”]でも可。
  • [siblings] 共通の親を持つ子ページ。[pagelist child_of=”parent”]でも可。
  • depth ? means how many levels in the hierarchy of pages are to be included in the list, by default depth is unlimited (depth=0), but you can specify it like this:
    [pagelist depth="3"]

    ;

  • if you want to show flat list of pages (not hierarchical tree) you can use this shortcode:
    [pagelist depth="-1"]

    ;

  • if you want to show subpages of the specific page you can use this shortcode:
    [pagelist child_of="4"]

    where

    4

    is the ID of the specific page;

  • if you want to exclude some pages from the list you can use this shortcode:
    [pagelist exclude="6,7,8"]

    where

    exclude

    parameter accepts comma-separated list of Page IDs;

  • if you want to exclude the tree of pages from the list you can use this shortcode:
    [pagelist exclude_tree="7,10"]

    where

    exclude_tree

    parameter accepts comma-separated list of Page IDs (all this pages and their subpages will be excluded);

  • if you want to include certain pages into the list of pages you can use this shortcode:
    [pagelist include="6,7,8"]

    where

    include

    parameter accepts comma-separated list of Page IDs;

  • if you want to specify the title of the list of pages you can use this shortcode:
    [pagelist title_li="<h2>List of pages</h2>"]

    ; by default there is no title (title_li=””);

  • if you want to specify the number of pages to be included into list of pages you can use this shortcode:
    [pagelist number="10"]

    ; by default the number is unlimited (number=””);

  • if you want to pass over (or displace) some pages you can use this shortcode:
    [pagelist offset="5"]

    ; by default there is no offset (offset=””);

  • if you want to include the pages that have this Custom Field Key you can use this shortcode:
    [pagelist meta_key="metakey" meta_value="metaval"]

    ;

  • if you want to show the date of the page you can use this shortcode:
    [pagelist show_date="created"]

    ; you can use this values for

    show_date

    parameter: created, modified, updated;

  • if you want to specify the column by what to sort you can use this shortcode:
    [pagelist sort_column="menu_order"]

    ; by default order columns are

    menu_order

    and

    post_title

    (sort_column=”menu_order, post_title”); you can use this values for

    sort_column

    parameter: post_title, menu_order, post_date (sort by creation time), post_modified (sort by last modified time), ID, post_author (sort by the page author’s numeric ID), post_name (sort by page slug);

  • if you want to change the sort order of the list of pages (either ascending or descending) you can use this shortcode:
    [pagelist sort_order="desc"]

    ; by default sort_order is

    asc

    (sort_order=”asc”); you can use this values for

    sort_order

    parameter: asc, desc;

  • if you want to specify the text or html that precedes the link text inside the link tag you can use this shortcode:
    [pagelist link_before="<span>"]

    ; you may specify html tags only in the

    HTML

    tab in your Rich-text editor;

  • if you want to specify the text or html that follows the link text inside the link tag you can use this shortcode:
    [pagelist link_after="</span>"]

    ; you may specify html tags only in the

    HTML

    tab in your Rich-text editor;

スポンサーリンク