- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
テンプレートタグ
目次
Template tags are used within your blog's Templates to display information dynamically or otherwise customize your blog, providing the tools to make it as individual and interesting as you are. Below is a list of the general user tags available in WordPress, sorted by function-specific category.
For further information on template tags and templates in general, see the following:
- Stepping Into Template Tags (テンプレートタグ入門)
- Anatomy of a Template Tag (テンプレートファイルでのタグの書き方の詳細)
- How to Pass Tag Parameters (パラメータの使い方の詳細)
- インクルードタグ (additional tags not shown here, related to including one Template file within another)
- 条件分岐タグ (more additional tags not shown here, related to making your Templates more flexible with options)
- Templates (テンプレート・テーマ・タグに関する総覧)
Note: If you have an interesting twist on the implementation of one or more tags, feel free to add an example for the benefit of other WordPress users.
注: いくつかのタグは、WordPress の特定のバージョンから新規追加(以下の一覧に "Version 2.1" のように注記)。いくつかのタグは、version 2.0.x で非推奨(以下に "非推奨" と注記)。いくつかのタグは、2.1 から非推奨(以下に "2.1 から非推奨" と注記)。
- プラグインとテーマの 2.1 への移行 (2.1 から非推奨となったタグと後継タグのリスト)
以下、各タグの概要の書き方を模索中。素直に表にした方が見やすいか…。
Author tags
- the_author
- the_author_description
- the_author_login
- the_author_firstname
- the_author_lastname
- the_author_nickname
- the_author_ID
- the_author_email
- the_author_url
- the_author_link (Version 2.1)
- the_author_icq
- the_author_aim
- the_author_yim
- the_author_msn
- the_author_posts
- the_author_posts_link
- list_authors (非推奨)
- wp_list_authors
Category tags
- the_category
- 現在の記事の全カテゴリを、そのカテゴリアーカイブへのリンク付きで表示。ループ中で使用。
- パラメータ: 区切り文字、親カテゴリを併記するか
- the_category_rss
- RSS で使用
- the_category_ID (非推奨)
- the_category_head (非推奨)
- single_cat_title
- category_description
- パラメータで指定したカテゴリの概要(カテゴリ管理画面で入力したもの)を取得。echo で表示。
- wp_dropdown_categories (Version 2.1)
- dropdown_cats (2.1 から非推奨)
- wp_list_categories (Version 2.1)
- list_cats (2.1 から非推奨)
- 機能は wp_list_cats と同様で、パラメータの書き方が異なる。こちらが古そう。2.0.x 系の EasyAll テーマで使用。
- → wp_list_categories
- wp_list_cats (2.1 から非推奨)
- リンク付きカテゴリリストを表示。そのリンクをクリックすると、当該カテゴリに属する全記事を テンプレート優先順位 に従ったカテゴリ・テンプレートを用いて表示。2.0.x 系のデフォルトテーマで使用。
- → wp_list_categories
- in_category
- 条件分岐タグの一つ。現在の記事がパラメータで指定したカテゴリに属するとき true を返す。ループ中で使用。ループ外で使うときは Use OUTSIDE The Loop 参照。
- get_category_parents
- 現在の または 指定したカテゴリと、そこから最上位までの各カテゴリを取得。echo で表示。
- get_the_category
- 現在の記事が属する各カテゴリの情報を取得。ループ中で使用。
- カテゴリID・カテゴリ名・カテゴリスラッグ・カテゴリ概要・親カテゴリが配列に格納されるので、好きなように取り出して使う。
Comment tags
- comments_number
- comments_link
- comments_rss_link
- comments_popup_script
- comments_popup_link
- comment_ID
- comment_author
- comment_author_IP
- comment_author_email
- comment_author_url
- comment_author_email_link
- comment_author_url_link
- comment_author_link
- comment_type
- comment_text
- comment_excerpt
- comment_date
- comment_time
- comment_author_rss
- comment_text_rss
- comment_link_rss
- permalink_comments_rss
Date and Time tags
- the_date_xml
- the_date
- 現在の記事の投稿日時を表示 or 取得。ループ中で使用。
- 1ページに同一投稿日の記事があれば、その最初の記事にのみ表示。全ての記事にも表示したいときは the_time を使用。
- パラメータ: 日時フォーマット、前後の文字、表示/取得
フォーマットを指定しなければ、管理画面 > オプション > 一般設定 - 日付のフォーマット で設定したフォーマット。 - the_time
- 現在の記事の投稿日時を表示。ループ中で使用。
- パラメータ: 日時フォーマット
指定しなければ、管理画面 > オプション > 一般設定 - 時間のフォーマット で設定したフォーマット。 - the_modified_date (Version 2.1)
- the_modified_time
- get_the_time (Version 1.5)
- single_month_title
- get_calendar
- the_weekday
- the_weekday_date
General tags
- bloginfo
- 設置した WordPress の各種情報(主に管理画面の一般設定やユーザープロフィールの項目)を表示。テンプレートのどこでも使える。sidebar.php や header.php でよく使われているので参考に。
- パラメータ: 表示したい項目を指定。ブログ名、URI、RSS、文字コード、設置ディレクトリURI、ほか
- 値を取得したいときは get_bloginfo を使用。
- bloginfo_rss
- get_bloginfo
- bloginfo と同様の項目の値を取得。PHP のどこでも使える。
- get_bloginfo_rss
- wp_title
- wp_get_archives
- 月別アーカイブリスト等、日付に基づくリンク付きアーカイブリストを表示。テンプレートのどこでも使える(サイドバーに限らない)。月・日・週別のほか、最近の投稿 n件のリストも可能。
- パラメータ: 種別、件数、リスト形式、前後の文字、記事数の表示
- get_archives (2.1 から非推奨)
- get_calendar
- get_posts
- マルチループ(複数ループ)の作成に使用。
- 参照: power source* » WP: テンプレートタグ get_posts で新着記事リスト等を表示
- wp_list_pages (Version 1.5)
- 「ページ」一覧を表示
- パラメータ: ソート順、除外/表示ページ、表示階層の深さ、サブページ指定、日付表示、リストの見出し有無、表示/取得
- wp_dropdown_pages
- wp_loginout (Version 1.5)
- wp_register (Version 1.5)
- query_posts (Version 1.5)
- rss_enclosure (Version 1.5)
- wp_tag_cloud (Version 2.3)
Geo tags
Geo features were moved to a plugin implementation with WordPress 1.5. Tags in parentheses are the plugin version.
- print_Lat (the_Lat)
- print_Lon (the_Lon)
- print_UrlPopNav (the_UrlPopNav)
- print_AcmeMap_Url (the_AcmeMap_Url)
- print_GeoURL_Url (the_GeoURL_Url)
- print_GeoCache_Url (the_GeoCache_Url)
- print_MapQuest_Url (the_MapQuest_Url)
- print_SideBit_Url (the_SideBit_Url)
- print_DegreeConfluence_Url (the_DegreeConfluence_Url)
- print_TopoZone_Url (the_TopoZone_Url)
- print_FindU_Url (the_FindU_Url)
- print_MapTech_Url (the_MapTech_Url)
Link tags
- edit_post_link
- edit_comment_link
- wp_link_pages
- link_pages (2.1から非推奨)
- get_year_link
- get_month_link
- get_day_link
Links Manager tags
- get_links_list
- 管理画面 > リンク で「表示:はい」になっている全てのリンクを、カテゴリ順に表示する。リンクカテゴリ画面の「カテゴリー設定」は有効だが、「フォーマット」は無視される。
- パラメータ: ソート順(カテゴリ名順/カテゴリID順。昇順/降順はアンダーバーで)
- wp_get_links
- パラメータで指定したカテゴリIDに属するリンクを表示。各リンクはカテゴリの「フォーマット」で設定したタグで括られるので、もしそれが <li> タグなら、<ul> タグや見出しの追加が必要。
- get_links
- wp_list_bookmarks (Version 2.1)
- wp_get_linksbyname (2.1 から非推奨)
- 全カテゴリまたは指定したカテゴリのリンクを、パラメータの条件に従って表示。
- get_linksbyname (2.1 から非推奨)
Permalink tags
- permalink_anchor
- get_permalink
- パラメータで ID を指定した記事のパーマリンクURI を取得。echo で表示。ループ中でパラメータなしで使うと、現在の記事のパーマリンクURI を取得。
- the_permalink
- 現在の記事のパーマリンクURI を表示。ループ中で使用。パラメータなし。
- permalink_single_rss
Post tags
- the_ID
- the_title
- single_post_title
- the_title_rss
- the_content
- 現在の記事の本文を表示。ループ中で使用。記事中に <!--more--> がある場合、単体記事ページ(パーマリンクページ)以外では、それより前の部分を表示し「続きを読む」リンクを添える。
- パラメータ: 「続きを読む」の文言、strip_teaser はよく分からない…。
- the_content_rss
- the_excerpt
- 現在の記事の抜粋を表示。「抜粋表示オプション」が空なら最初の120語を出力。HTMLタグや画像は除外。ループ中で使用。パラメータなし。
- 日本語だと長文が出てしまう問題の対応策は、パッチかプラグイン。
- the_excerpt_rss
- previous_post_link
- previous_post (非推奨)
- next_post_link
- next_post (非推奨)
- posts_nav_link
- the_tags (Version 2.3)
Trackback tags
External Resources
- szub.net: WordPress Template Tags reference page
- Solutoire.com: Template Tag Dreamweaver extension (TAGStention)
- Wptags.com -- テンプレートタグの機能と使い方を日本語で説明
- power source* » WP: テンプレートタグ機能一覧 -- 上に記入した概要の元データ