Skip to content

Instantly share code, notes, and snippets.

@huanyichuang
Last active February 19, 2020 02:23
Show Gist options
  • Save huanyichuang/5e088daac37159fe9c271d8325e9c086 to your computer and use it in GitHub Desktop.
Save huanyichuang/5e088daac37159fe9c271d8325e9c086 to your computer and use it in GitHub Desktop.
<?php
function reservation_register_meta() {
global $post;
if ( 'page-shopreservations.php' != get_post_meta( $post->ID, '_wp_page_template', true ) ) {
//忘記 $post 是一個物件 XD 要再把 ID 指定起來
return;
} else {
add_meta_box(
'reservation-form-id',
'MW WP Form ID',
'reservation_meta_callback',
'page' );
}
}
add_action( 'add_meta_boxes', 'reservation_register_meta' );
function reservation_meta_callback( $post ) {
$value = get_post_meta($post->ID, '_reservation_id', true);
?>
<label for="reservation_id">ID of MW WP Form</label>
<input type="text" id="reservation_id" name="reservation_id" class="postbox">
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment