i need to add some detail to posts, so i have to modify page to add/update post
but i don't know what action i should to use
i want to add two select boxes, admin must select first field and then choose second too
for example fields are :
List One, List Two, List Three, List Four
And Sub Selects :
List One : Item One, Item Two, Item Three, Item Four
List Two : Item One, Item Two, Item Three, Item Four
php Code :
// ============================== Add Province And City ...
add_action( 'add_meta_boxes', 'selectIranProvinceCity' );
add_action( 'save_post', 'iranProvinceCitySavePostData' );
function selectIranProvinceCity(){
// require_once( 'iran_province_city.php' );
}
function iranProvinceCitySavePostData(){
// Save Province And City
$province = '';
$city = '';
if( isset( $_POST['state'] ) ) {
$province = $_POST['state'];
}
if( isset( $_POST['city'] ) ) {
$city = $_POST['city'];
}
$post_id = get_the_ID();
if( !add_post_meta($post_id, 'province', $province, true ) ) {
update_post_meta($post_id, 'province', $province, true );
}
if( !add_post_meta($post_id, 'city', $city, true ) ) {
update_post_meta($post_id, 'city', $city, true );
}
}
// ============================== Add Province And City .
But no value save on update, $post_id
is always null