Default meta - Custom field

<?php

//Set Default Meta Value
function set_default_meta($post_ID){
$current_field_value = get_post_meta($post_ID,'Sort Order',true);
$default_meta = '100';

if ($current_field_value == '' && !wp_is_post_revision($post_ID)){
add_post_meta($post_ID,'Sort Order',$default_meta,true);
}
return $post_ID;
}

add_action('wp_insert_post','set_default_meta');

?>

0 Comments

You must be logged in to post a comment.