Skip to content

Instantly share code, notes, and snippets.

@vishnusomanus
Created February 16, 2017 11:36
Show Gist options
  • Save vishnusomanus/44846c88852a85d61f4deed92b7bf4b0 to your computer and use it in GitHub Desktop.
Save vishnusomanus/44846c88852a85d61f4deed92b7bf4b0 to your computer and use it in GitHub Desktop.
//add in function.php
<?php
add_action( 'add_meta_boxes', 'flatfee_field' );
function flatfee_field() {
global $post;
if($post->ID == '40')//40 is page id
add_meta_box("flatfee", "Flatfee", "add_flatfee", "page", "normal", "high");
}
function add_flatfee(){
global $post;
$custom = get_post_custom($post->ID);
$flatfee = $custom["flatfee"][0];
?>
<input class="custom_input" name="flatfee" value="<?php echo $flatfee; ?>" />
<?php
}
function update_flatfee( $post_id ) {
if($post_id == 40)
{
update_post_meta(40,'flatfee',$_POST['flatfee']);
}
}
add_action( 'save_post', 'update_flatfee' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment