如果将两个输入字段的内容保存到一个post\\u元值中,则可以立即调用它们。
In the save_post
action
$text = esc_attr( $_POST[\'text\'] );
$select = esc_attr( $_POST[\'select\'] );
// saves the value as "text select"
$combined = trim( sprintf( \'%1$s %2$s\', $text, $select ) );
update_post_meta( $post_id, \'The_ID\', $combined );
Get Post Meta
if ( $the_id = get_post_meta( $post->ID, \'The_ID\', true ) )
echo $the_id;
另一种方法是在序列化数组中添加所有信息,然后保存。
In the save_post
action
$text = esc_attr( $_POST[\'text\'] );
$select = esc_attr( $_post[\'select\'] );
$combined = serialize( array(
\'text\' => $text,
\'select\' => $select
) );
update_post_meta( $post_id, \'The_ID\', $combined );
Get Post Meta
if ( $the_id = get_post_meta( $post->ID, \'The_ID\', true ) )
$the_id = unserialize( $the_id );
$the_id
将包含一个值为的数组
text
和
select
.