store arrays in a custom field in post (ok)
lưu trữ mảng trong một trường tùy chỉnh
// header.php
<?php
echo '<pre>';
var_export(get_post_meta(1,'customfield1'));
echo '</pre>';
?>
// function.php
// Add a custom action on save post so we can convert our custom format
add_action( 'save_post', 'smyles_save_post_format_custom_field');
function smyles_save_post_format_custom_field(){
$metas = $_POST['meta'];
$post_id = get_the_ID();
foreach ($metas as $key => $value) {
$custom_field = explode(',', $value['value']);
update_post_meta($post_id,$metas[$key]['key'],$custom_field);
}
}



Last updated
Was this helpful?