Wordpress元框保存不为';行不通
我无法理解为什么事件开始日期为时事件价格和事件位置不保存。我已经从各个方面对此进行了测试,但它仍然没有保存数据Wordpress元框保存不为';行不通,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我无法理解为什么事件开始日期为时事件价格和事件位置不保存。我已经从各个方面对此进行了测试,但它仍然没有保存数据 function event_detail_box_content() { global $post; $custom = get_post_custom($post->ID); $meta_sd = $custom["events_startdate"][0]; $meta_pr = isset( $custom['events_price
function event_detail_box_content() {
global $post;
$custom = get_post_custom($post->ID);
$meta_sd = $custom["events_startdate"][0];
$meta_pr = isset( $custom['events_price'] ) ? esc_attr( $custom["events_price"][0]): ”;
$meta_lo = $custom["events_location"][0];
$meta_st = $meta_sd;
$time_format = get_option('time_format');
if ($meta_sd == null) { $meta_sd = time(); $meta_st = 0;}
$clean_sd = date("D, M d, Y", $meta_sd);
$clean_st = date($time_format, $meta_st);
wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
?>
<div class="tf-meta">
<ul>
<li><label>Event Date</label><input name="events_startdate" class="tfdate" value="<?php echo $clean_sd; ?>" /></li>
<li><label>Event Time</label><input name="events_starttime" value="<?php echo $clean_st; ?>" /><em>Use 24h format (7pm = 19:00)</em></li>
<li><label>Event Price</label><input name="events_price" value="<?php echo $meta_pr; ?>" /></li>
<li><label>Event Location</label><input name="events_location" value="<?php echo $meta_lo; ?>" /></li>
</ul>
</div>
<?php
print_r($custom);
}
add_action ('save_post', 'save_events');
function save_events($post_id){
if ( !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
if ( !current_user_can( 'edit_post')) return;
if(!isset($_POST["events_startdate"])): return; endif;
$updatestartd = strtotime ( $_POST["events_startdate"] . $_POST["events_starttime"] );
update_post_meta($post_id, "events_startdate", $updatestartd );
update_post_meta($post_id, "events_price", $POST["events_price"] );
update_post_meta($post_id, "events_location", $POST["events_location"] );
}
功能事件\u详细信息\u框\u内容(){
全球$员额;
$custom=get\u post\u custom($post->ID);
$meta_sd=$custom[“事件开始日期”][0];
$meta_pr=isset($custom['events_price'])?esc_attr($custom[“events_price”][0]):“;
$meta_lo=$custom[“事件位置”][0];
$meta_st=$meta_sd;
$time\u format=get\u选项(“time\u format”);
如果($meta_sd==null){$meta_sd=time();$meta_st=0;}
$clean_sd=日期(“D,md,Y”,$meta_sd);
$clean\u st=日期($time\u格式,$meta\u st);
wp_nonce_字段('my_meta_box_nonce','meta_box_nonce');
?>
- 事件日期您的
$\u POST
变量上缺少下划线
update_post_meta($post_id, "events_price", $POST["events_price"] );
update_post_meta($post_id, "events_location", $POST["events_location"] );
应该是
update_post_meta($post_id, "events_price", $_POST["events_price"] );
update_post_meta($post_id, "events_location", $_POST["events_location"] );
$\u POST
变量上缺少下划线
update_post_meta($post_id, "events_price", $POST["events_price"] );
update_post_meta($post_id, "events_location", $POST["events_location"] );
应该是
update_post_meta($post_id, "events_price", $_POST["events_price"] );
update_post_meta($post_id, "events_location", $_POST["events_location"] );