前提
wordpressのSmart Custom Fieldsプラグインで、
管理画面からではなくフロントページから投稿できるフォームを作成しいたのですが、
画像を投稿する為の記述をどのように書けばいいか知りたいです。
試したこと
<?php $scf_posts = get_posts(array( 'post_type' => 'smart-custom-fields', 'order' => 'DESC', 'meta_query' => array( array( 'key' => '〇〇', 'value' => '〇〇', 'compare' => 'LIKE', ), ) )); foreach ($scf_posts as $scf_post) { $scf_id = $scf_post->ID; $scf_settings = get_post_meta($scf_id, '〇〇', true); // 中略 foreach ($scf_settings as $item) { $form_item_tag = ''; switch ($item['fields'][0]['type']) { case "text": // テキストボックス $form_item_tag = $form_item_tag . '<div class="">'; $form_item_tag = $form_item_tag . '<input type="text" class="" value="' . $item['fields'][0]['default'] . '" id="' . $item['fields'][0]['name'] . '" name="' . $item['fields'][0]['name'] . '" >'; $form_item_tag = $form_item_tag . '<div class="errortext" style="display:none;"></div>'; $form_item_tag = $form_item_tag . '</div>'; break; } } }
上記でテキストフィールドはうまくいったのですが、
ここに case "image": として、画像に関してどのように記述すればうまくいくか分からず、知恵をお貸し頂ければと思います。
よろしくお願い致します。
あなたの回答
tips
プレビュー