カスタムフィールドテンプレートのtype = fieldset_openとtype = fieldset_closeを利用して、自由に増やせるフィールドセットを作ることができます。
これの表示に手間取ったのでオプション設定と表示方法をメモしておきます。
カスタムフィールドテンプレートのオプション設定
[sample_fieldset] type = fieldset_open legend = サンプルセット class=sample multiple = true multipleButton = true [sample_title] label = 種別 type = textfield size = 50 blank = true [sample_address] label = 住所 type = textfield size = 50 blank = true [sample_img] label = 画像 type = file blank = true [sample_fieldset] type = fieldset_close
テンプレートで表示
※ $post_id にはポストIDが入るようにしてください。
$sample_title = get_post_meta($post_id, "sample_title", false);
$sample_address = get_post_meta($post_id, "sample_address", false);
$sample_img = get_post_meta($post_id, "sample_img", false);
if ($sample_title[0]) {
$base_sample = array();
$length = count($sample_title);
for ($i = 0; $i < $length; $i++) {
$tmp = array($sample_title[$i], $sample_address[$i], wp_get_attachment_url($sample_img[$i]));
array_push($base_sample, $tmp);
}
}
<?php foreach ($base_sample as $x) { ?>
種別:<?php echo $x[0]; ?><br />
住所:<?php echo $x[0]; ?><br />
画像:<img src="<?php echo $x[0]; ?>" alt="" />
<?php } ?>


