【WORDPRESSプラグイン】カスタムフィールドテンプレート(Custom Field Template)でひっかかったこと

本当節操のないブログで申し訳ありません。

ワードプレスはググれば沢山記事がありますが備忘録としてメモ。

カスタムフィールドテンプレートでfileを出力させる

ワードプレスCMS的に使いたかったのでワードプレス標準のカスタムフィールドを簡単にカスタマイズできるプラグインを探しました。

で、Wordpressの部屋というサイト様を拝見しうまくいきましたが、fileを簡単にアップロードして簡単に表示できるようにする点で引っかかりました。
※簡単に、という点を除けばワードプレス標準のhtmlエディターでできちゃいますがそれは嫌だったのです。

Wordpressの部屋



TEMPLATE #1

[name]
type = textfield
size = 50
hidekey = true


[company]
type = textfield
size = 50
hidekey = true

[TEL]
type = textfield
size = 50
hidekey = true

[URL]
type = textfield
size = 50
hidekey = true

[facebookURL]
type = textfield
size = 100
hidekey = true

[twitterURL]
type = textfield
size = 100
hidekey = true

[delivery]
type = textarea
rows = 4
cols = 40
tinyMCE = true
htmlEditor = true
mediaButton = true

[return process]
type = textarea
rows = 4
cols = 40
tinyMCE = true
htmlEditor = true
mediaButton = true

[rank]
type = radio
value = 1 # 2 # 3 # 4
default = 1
clearButton = true

[banner]
type = file
label = 画像(250x250に近い形で)を登録してください

[cft]and[cftsearch]ShortCode Format

大事なのは

<?php echo wp_get_attachment_image(post_custom('banner')); ?>

のところ。このコードで表示します。
一応[cft]and[cftsearch]ShortCode Formatを全部貼り付けました。


<table class="custombox">
<tbody>
<tr>
<th>name</th><td colspan="3">[name]</td>
</tr>
<tr>
<th>company</th><td>[company]</td>
</tr>
<tr>
<th>TEL</th><td>[TEL]</td>
</tr>
<tr>
<th>URL</th><td colspan="3">[URL]</td>
</tr>
<tr>
<th>facebookURL</th><td colspan="3"><a href="[facebookURL]">[facebookURL]</a></td>
</tr>
<tr>
<th>twitterURL</th><td colspan="3"><a href="[twitterURL]">[twitterURL]</a></td>
</tr>
<tr>
<th>delivery</th><td colspan="3">[delivery]</td>
</tr>
<tr>
<th>return process</th><td colspan="3">[return process]</td>
</tr>
<tr><th>rank</th><td colspan="3">[rank]</td></tr><tr>
<th>banner</th><td colspan="3"><?php echo wp_get_attachment_image(post_custom('banner')); ?></td>
</tr>
</tbody>
</table>

PHPを使用するにチェックしてくださいね。
チェックしないと表示されませんので要注意です。

■参考リンク
custom-field-template本家