お客様からの要望で実装したので覚書。
MW WP Form:
1 2 3 4 |
<dl> <dt><span class="req">必須</span>体験ツアー</dt> <dd>[mwform_select name="tour"]</dd> </dl> |
functions.phpに追記
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function add_form_tour_name( $children, $atts ) { // フォームのname属性が「tour」の場合にカスタマイズ if($atts['name'] == 'tour'){ $tours = get_posts( array( 'post_type' => 'tour', // 投稿タイプ名 'posts_per_page' => -1 )); foreach($tours as $tour){ $children[$tour->post_title] = $tour->post_title; } } return $children; } // フック名のxxxの部分はフォームID add_filter( 'mwform_choices_mw-wp-form-xxxxx', 'add_form_tour_name', 10, 2 ); |