我最终做的是将我需要的数据存储在post_meta
保存时的表格:
add_action( \'save_post\', \'mouldings_hidden_postmeta\' );
function mouldings_hidden_postmeta() {
global $post;
if (is_admin() && (get_post_type() == \'moulding_profiles\' || get_post_type() == \'moulding_combination\')) {
$mouldings_meta_keys = array(
\'_mouldings_dimensions_width\',
\'_mouldings_dimensions_height\',
\'_mouldings_projection_width\',
\'_mouldings_projection_height\'
);
foreach ($mouldings_meta_keys as $mouldings_meta_key) {
if(get_post_type() == \'moulding_profiles\' && ($mouldings_meta_key == \'_mouldings_projection_width\' || $mouldings_meta_key == \'_mouldings_projection_height\')) {
continue;
}
if(!get_post_meta($post->ID, $mouldings_meta_key)) {
add_post_meta($post->ID, $mouldings_meta_key, fraction_to_decimal(get_field(str_replace(\'_mouldings_\', \'mp_profile_\', $mouldings_meta_key))));
}
else {
update_post_meta($post->ID, $mouldings_meta_key, fraction_to_decimal(get_field(str_replace(\'_mouldings_\', \'mp_profile_\', $mouldings_meta_key))));
}
}
}
}