WordPressカスタムフィールドテンプレート

出力を決まった形式にしたい場合は
入力項目をそれに合わせる必要がある。
例えば、作品名、制作者、ホームページ・ブログタイトル、ホームページ・ブログURL、作品説明、画像

そんな時は
Custom Field Template pluginが便利そう

参考サイト
http://wpgogo.com/development/custom-field-template.html
http://www.odysseygate.com/archives/1624

①プラグインをインストールし有効化後、
プラグインのCustom Field Templateの設定
から、テンプレートコンテンツを編集

こんな感じ
[workTitle]
type = text
size = 35
label = 作品名
output = true

[creatorName]
type = text
size = 35
label = 制作者
output = true

[HP]
type = text
size = 35
label = ホームページ・ブログタイトル
output = true

[URL]
type = text
size = 255
label = ホームページ・ブログURL
output = true

[setsumei]
type = textarea
rows = 4
cols = 40
tinyMCE = true
htmlEditor = true
mediaButton = true
label = 作品説明
output = true

[File Upload]
type = file
output = true

テンプレートを追加して、変更できるのも便利

②投稿-新規追加
以下のように設定できるようになる。
001

③これを表示するには
新規追加の投稿欄に[cft]と入れてもいいのだが、柔軟性が無いので
index.phpなどのテーマファイルに直接記述する
ワードプレスループの中で以下のようにする。
ID,’URL’,TRUE) . “
“;
echo get_post_meta($post->ID,’setsumei’,TRUE). “
“;
$id = get_post_meta($post->ID,’File Upload’,TRUE);
echo get_post_meta($id,’_wp_attached_file’,TRUE). “
“;
?>