无法在wordpress中更新选项,始终返回false

时间:2018-11-16 19:42:48

标签: wordpress

    //Getting data via Ajax
    $preff = $_POST['preff'];
    $input['type'] = $_POST['type'];
    $input['Availability'] = $_POST['Availability'];

    //get the existed data 
    $output = get_option($preff);

    //Check if data new add it to the array, or update 
    When its exist
    if($input['type'] != ''){
    $found = false;
    foreach($output as $key => $value){
        if($value['type'] === $input['type']){
            $output[$key] = $input;
            $found = true;
        }

    }
    if(!$found){
        $output[] = $input;
    }
    }


    //update option 
    var_dump(update_option($preff, $output));

我正在尝试更新选项,但始终返回false。设置Api已经使用了一些键,但是我需要在不重新加载页面的情况下动态更新数据。

0 个答案:

没有答案