function tell_me() { header("Access-Control-Allow-Origin: *"); header("Content-Type: application/json; charset=utf-8"); $name = array(); $args = array( 'cat' => 1, 'posts_per_page' => 1000 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); $custom_fields = get_post_custom(); // 指定した投稿のすべてのカスタムフィールド情報を取得 $my_custom_field = $custom_fields['name']; // '' というキーを持つカスタムフィールドの値を取得 foreach ( $my_custom_field as $key => $value ) $name[] = $value; endwhile; endif; wp_reset_postdata(); $res = $name; echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); }