• サイトデザイン工事中です。ご意見をお寄せください
  • 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

テンプレートタグ/the widget

提供:WordPress Codex 日本語版
移動: 案内, 検索

このページ「テンプレートタグ/the widget」はまだ書きかけで、情報が不足しています。続きを書いて WordPress を手助けしましょう

  • 英語版はまだないのでソースから書き起こしています。使い方や設定方法など間違っていたら遠慮なく手を入れてください。(直に書き換えても、ノートにメモってくれても OK です)
  • 説明や使用例を追加してください。

目次

説明

テンプレートタグ the_widget() は、任意のウィジェットを出力します。テンプレートのどこでも使えます。

使い方

<?php the_widget($widget, $instance, $args); ?>

パラメータ

widget
(文字列) ウィジェットの PHP クラス名
instance
(配列またはクエリ文字列型) ウィジェットのインスタンス設定(下記の各ウィジェットを参照)
args
(配列またはクエリ文字列型) ウィジェットのサイドバー引数
before_widget
(文字列) ウィジェットの前に出力するテキストまたは HTML
初期値: <div class="widget ウィジェットのクラス名">
after_widget
(文字列) ウィジェットの後ろに出力するテキストまたは HTML
初期値: </div>
before_title
(文字列) 見出しの前に出力するテキストまたは HTML
初期値: <h2 class="widgettitle">
after_title
(文字列) 見出しの後ろに出力するテキストまたは HTML
初期値: </h2>
例:
<?php the_widget('WP_Widget_Pages', '', 'before_title=<h3>&after_title=</h3>'); ?>

アーカイブ・ウィジェット

月別アーカイブリストを出力します。

<?php the_widget('WP_Widget_Archives', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Archives'); ?>

ドロップダウン形式で月別アーカイブリストを出力:

<?php the_widget('WP_Widget_Archives', 'dropdown=1'); ?>

カレンダー・ウィジェット

カレンダーを出力します。

<?php the_widget('WP_Widget_Calendar', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Calendar'); ?>

カテゴリー・ウィジェット

カテゴリーリストを出力します。

<?php the_widget('WP_Widget_Categories', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Categories'); ?>

ドロップダウンリストで、投稿数も表示する:

<?php the_widget('WP_Widget_Categories', 'dropdown=1&count=1'); ?>

リンクリストを出力します。

<?php the_widget('WP_Widget_Links', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Links'); ?>

リンクカテゴリID 2, 3 のみを出力:

<?php the_widget('WP_Widget_Links', 'category=2,3'); ?>

メタ・ウィジェット

サイトのメタ情報(ログイン/アウト、フィードリンク、wordpress.org へのリンク)を出力します。

<?php the_widget('WP_Widget_Meta', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Meta'); ?>

ページ・ウィジェット

ページリストを表示します。

<?php the_widget('WP_Widget_Pages', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Pages'); ?>

見出しを <h3>コンテンツ</h3> に変更し、更新順に表示:

<?php the_widget('WP_Widget_Pages', 'title=コンテンツ&sortby=post_modified', 'before_title=<h3>&after_title=</h3>'); ?>

最近のコメント・ウィジェット

<?php the_widget('WP_Widget_Recent_Comments', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Recent_Comments'); ?>

最近の投稿・ウィジェット

<?php the_widget('WP_Widget_Recent_Posts', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Recent_Posts'); ?>

RSS ウィジェット

<?php the_widget('WP_Widget_RSS', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_RSS'); ?>

検索ウィジェット

<?php the_widget('WP_Widget_Search', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Search'); ?>

タグクラウド・ウィジェット

<?php the_widget( 'WP_Widget_Tag_Cloud', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget( 'WP_Widget_Tag_Cloud'); ?>

テキスト・ウィジェット

<?php the_widget('WP_Widget_Text', $instance, $args); ?>

用例

初期設定のまま使用:

<?php the_widget('WP_Widget_Text'); ?>

変更履歴

参考

関連

個人用ツール
名前空間
変種
操作
このサイトについて
特集
サーバ別情報
リファレンス
ドキュメント整備
ツールボックス
他の言語