カスタムフィールドを使いやすくする Custom Field Template
ダウンロードは以下から
Custom Field Template
設定のテンプレートコンテンツには、以下のように入力する
[Plan] type = text size = 35 label = Where are you going to go? [Plan] type = textfield size = 35 hideKey = true [Favorite Fruits] type = checkbox value = apple # orange # banana # grape default = orange # grape [Miles Walked] type = radio value = 0-9 # 10-19 # 20+ default = 10-19 clearButton = true [Temper Level] type = select value = High # Medium # Low default = Low [Hidden Thought] type = textarea rows = 4 cols = 40 tinyMCE = true htmlEditor = true mediaButton = true [File Upload] type = file
また、テンプレートファイルには、以下のように追記する。
■テキストを表示させる例
<?php echo get_post_meta($post->ID,'住所', true);?>
■画像を表示させる例
<?php echo wp_get_attachment_image(post_custom('メインイメージ'),'originalImage'); ?>
■googleマップを表示させる例
<iframe width="580" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps?q=<?php echo get_post_meta($post->ID,'住所',true); ?>&z=25&output=embed"></iframe><br /><a href="http://maps.google.co.jp/maps?q=<?php echo get_post_meta($post->ID,'住所',true); ?>&gl=jp&t=m&z=25&iwloc=A&source=embed" target="_blank">大きな地図で見る</a>