我正在撰寫一個 WordPress 插件,但在創建 WordPress 元資料時遇到了問題。
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wp_api_savee_prices_metabox' not found or invalid function name in C:\laragon\www\wordpress\wp-includes\class-wp-hook.php on line ???
請指導我。謝謝
我的metabox檔案代碼:
<?php
function wp_api_add_price_metabox($post_type, $post)
{
add_meta_box(
'wpapimetabox',
'???? ????',
'wp_api_price_metabox_handler',
'post',
'normal',
'default'
);
function wp_api_price_metabox_handler($post)
{
?>
<label for="txt1">???? ?? ???? ????:</label>
<input type="text" id="txt1" name="wp_api_post_prices">
<?php
}
function wp_api_savee_prices_metabox($post_id)
{
if(isset($_POST['wp_api_post_prices']))
{
update_post_meta($post_id,'wp_api_prices',$_POST['wp_api_post_prices']);
}
}
}
add_action('add_meta_boxes', 'wp_api_add_price_metabox', 10, 2);
add_action('save_post','wp_api_savee_prices_metabox');
注意:我正在為帖子創建元資料。
uj5u.com熱心網友回復:
你已經wp_api_savee_prices_metabox在里面添加了功能wp_api_add_price_metabox試試下面的代碼。
function wp_api_add_price_metabox($post_type, $post){
add_meta_box(
'wpapimetabox',
'???? ????',
'wp_api_price_metabox_handler',
'post',
'normal',
'default'
);
}
add_action('add_meta_boxes', 'wp_api_add_price_metabox', 10, 2);
function wp_api_price_metabox_handler($post){
?>
<label for="txt1">???? ?? ???? ????:</label>
<input type="text" id="txt1" name="wp_api_post_prices">
<?php
}
function wp_api_savee_prices_metabox($post_id){
if(isset($_POST['wp_api_post_prices']))
{
update_post_meta($post_id,'wp_api_prices',$_POST['wp_api_post_prices']);
}
}
add_action('save_post','wp_api_savee_prices_metabox');
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/336506.html
標籤:php WordPress的
