WP REST API:register_rest_field update_callback无法正常工作

时间:2019-01-20 13:53:52

标签: wordpress wordpress-rest-api

在functions.php中,我具有以下简化功能:

function registerRowsField() {
register_rest_field('page', 'rows', array(
    'get_callback' => function() {
        return true;
    },
    'update_callback' => function() {
        error_log("ran update callback");
        return false;
    }
));
}
add_action('rest_api_init', 'registerRowsField');

该字段显示在API中,值为true(好东西)。调用update_callback时,error_log("ran update callback")会显示在我的日志中,但是rows的值不会更新为false(不好的东西)。

如何获取update_callback函数来实际更新并将新值保存到rows

0 个答案:

没有答案