MW WP Form(チェックボックスの場合)
[mwform_checkbox name="mwform_item" class="mwform_item"]
functions.php
function add_item_list( $children, $atts ) {
if ( 'item' == $atts['name'] ) {
$items = get_posts( array(
'post_type' => 'item',//カスタム投稿タイプのスラッグ
'posts_per_page' => -1,
) );
foreach ( $items as $item ) {
$children[$item->post_title] = $item->post_title;
}
}
return $children;
}
add_filter( 'mwform_choices_mw-wp-form-xx', 'add_item_list', 10, 2 );
コメント