add_action('rest_api_init', function() { $fields = [ '_yoast_wpseo_focuskw', '_yoast_wpseo_metadesc', '_yoast_wpseo_title', ]; foreach ($fields as $field) { register_meta('post', $field, [ 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'auth_callback' => function() { return current_user_can('edit_posts'); } ]); } });