我通过强制第二次刷新找到了一个解决方法,但我相信可能有更好的方法来做到这一点。
为了让用户更顺利地完成这个过程,我想我必须先发布一篇AJAX文章,然后在成功后刷新以显示更新的数据。
<小时>
if ( isset($_POST[\'deleteSelectedCategories\']) ){
    $cats = $_POST[\'catsToDelete\'];
    $catsArray = explode(\',\', $cats);
    $success = 0;
    foreach ($catsArray as $catID) {
        if ( wp_delete_term( $catID, \'category\' ) ) {
            $success++;
        }
    }
    if ($success > 0) {
        echo \'[Here I have some HTML to block out the screen 
            and show a message to the user, 
            and then the following meta refresh:] 
            <meta http-equiv="refresh" content="0" />\';
    }
}