私はグーグルをしましたが、原子的に値を与える方法がわかりません
add_post_meta(0, key , 公開時)
この機能は、公開後に価値を追加することができます
function add_custom_field_automatically($post_ID) { global $wpdb;
if(!wp_is_post_revision($post_ID)) {
add_post_meta($post_ID, '_my_key', '0', true);
}
}
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post', 'add_custom_field_automatically');
これにより、カスタムフィールドが自動的に追加されます
function add_custom_field_automatically($post_ID) { global $wpdb;
if(!wp_is_post_revision($post_ID)) {
add_post_meta($post_ID, '_my_key', '0', true);
}
}
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_cystom_post_type', 'add_custom_field_automatically'