• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

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

ショートコード

提供: WordPress Codex 日本語版
2013年8月18日 (日) 22:30時点におけるDjkaz (トーク | 投稿記録)による版 (英語版をコピペ。)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Since Version 2.5 WordPress support so called Shortcodes. They have been introduced for creating macros to be use in a posts content. For examples of shortcodes and how to use them, see WordPress.com Shortcodes, though some shortcodes featured are exclusive to WordPress.com.

A trivial shortcode for a gallery looks like this:

[gallery]

You can also print a shortcode directly in a template like so:

 <?php echo do_shortcode('[gallery]'); ?>

Shortcodes can be with additional attributes as the following example shows:

[gallery id="123" size="medium"]

Both examples will display an image gallery which would be hard to maintain when writing the HTML markup for it and keeping it in sync with uploaded images.


Built-In and Additional Shortcodes

WordPress does offer some of the shortcodes by default (for example the gallery one) and plugins can add their own as well via the Shortcode API.