在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
?