Код: Выделить всё
function notifyem_save_post() {
if(empty($_POST)) return; //why is prefix_teammembers_save_post triggered by add new?
global $post;
update_post_meta($post->ID, "country", $_POST["country"]);
update_post_meta($post->ID, "region", $_POST["region"]);
update_post_meta($post->ID, "time", $_POST["time"]);
update_post_meta($post->ID, "activity", $_POST["activity"]);
}
Код: Выделить всё
[{"title":"john"},{"title":"xxx"},{"title":"11"}]
Код: Выделить всё
function notifyem_rest_get() {
$subscriptions = new WP_Query(array(
'post_type' => 'notifyem'
));
$subscriptionResults = array();
register_rest_route('notifyemAPI/v1', '/subscription', array(
'methods' => WP_REST_SERVER::READABLE,
'callback' => array($this, 'getSubscription')
));
}
function getSubscription() {
$subscriptions = new WP_Query(array(
'post_type' => 'notifyem',
'meta_key' => 'country'
));
$subscriptionResults = array();
while($subscriptions->have_posts()) {
$subscriptions->the_post();
array_push($subscriptionResults, array(
'region' => get_field('regi'),
'country' => get_field('country'),
'activity' => get_field('activity'),
'time' => get_field('time')
));
}
return $subscriptionResults;
}

Есть идеи, как получить настраиваемые поля, которые я создал в своем REST API?
Подробнее здесь: https://stackoverflow.com/questions/487 ... i-meta-key
Мобильная версия