我正在为一支运动队创建一个wp网站。在主仪表板上,我想创建一个简单的小部件,允许管理员更新团队记录。然后在页面模板上,我想呼应出该内容。
我可以使用ACF将自定义字段添加到相关页面的页面编辑器中,但我希望在仪表板上显示这些字段以提高可见性。
这是我到目前为止所拥有的,我可以让表单显示出来,但我不能将其提交给db来存储数据。在我的功能中。php(稍后将移动到特定于站点的插件)。我的问题主要在于表单操作和$control\\u回调
// Function that outputs the contents of the dashboard widget
function dashboard_widget_function( $post, $callback_args ) {
echo \'<form id="record" method="POST" action="//Should this point to a function or endpoint?"><input type="text" name="wins" id="wins" placeholder="wins">\'
.\'<input type="text" name="losses" id="losses" placeholder="losses"><input type="submit" value="update"></form>\';
}
function dashboard_widget_submit( $post, $callback_args ){
//No idea what to do here
}
// Function used in the action hook
function add_dashboard_widgets() {
wp_add_dashboard_widget(\'dashboard_widget\', \'Stars Record\', \'dashboard_widget_function\', \'dashboard_widget_submit\');
}
// Register the new dashboard widget with the \'wp_dashboard_setup\' action
add_action(\'wp_dashboard_setup\', \'add_dashboard_widgets\' );