代表的な記事リストのテンプレートタグのショートコード化

コンサデコンサやログブックで良く使う代表的な記事リストのテンプレートタグのショートコード化の覚書。

変数をarrayで列記していないので、ショートコード内で指定する。


【wp_list_pagesの場合】

[php]
/**
* ショートコード-固定ページのタイトルリスト表示
*/

function list03( $args=” ) {
$args[‘echo’] = false; // This is necessary to stop the output from printing before the actual page content
$output = ‘

    ‘.wp_list_pages($args).’

‘;
return $output;
}
add_shortcode(‘page_list03’, ‘list03’);
[/php]

変数は、ショートコード内で指定する。
【例】
[php]


    [/php]


    【wp_list_categoriesの場合】

    [php]
    /**
    * ショートコード-カテゴリーのタイトルリスト表示
    */

    function list04( $args=” ) {
    $args[‘echo’] = false; // This is necessary to stop the output from printing before the actual page content
    $output = ‘

      ‘.wp_list_categories($args).’

    ‘;
    return $output;
    }
    add_shortcode(‘page_list04’, ‘list04’);
    [/php]

    変数は、ショートコード内で指定する。
    【例】
    [php]


    [/php]


    【wp_get_archivesの場合】

    [php]
    /**
    * ショートコード-月別アーカイブのタイトルリスト表示
    */

    function list05( $args=” ) {
    $args[‘echo’] = false; // This is necessary to stop the output from printing before the actual page content
    $output = ‘

      ‘.wp_get_archives($args).’

    ‘;
    return $output;
    }
    add_shortcode(‘page_list05’, ‘list05’);
    [/php]

    変数は、ショートコード内で指定する。
    【例】
    [php]


    [/php]

    コメントを残す

    メールアドレスが公開されることはありません。 が付いている欄は必須項目です