我已经创建了名为booking的自定义帖子类型。它有一个元booking_first_name
, booking_last_name
, booking_email
, booking_phone
, booking_phone_contact
. 目前,我成功地显示了电子邮件、电话和手机。
但是,我想将我的帖子标题显示为booking_first_name
+ booking_last_name
. 我怎么能那样做?
以下是我当前的语法:
<?php
/**
* Register custom admin field
*/
add_filter(\'manage_booking_posts_columns\', \'booking_table_head\');
function booking_table_head( $defaults ) {
$defaults[\'booking_email\'] = \'Email\';
$defaults[\'booking_contact_phone\'] = \'Contact Phone\';
$defaults[\'booking_mobile_phone\'] = \'Mobile Phone\';
return $defaults;
}
/**
* Fill custom field value
*/
add_action(\'manage_booking_posts_custom_column\', \'booking_table_content\', 10, 2);
function booking_table_content( $column_name, $post_id ) {
switch ($column_name) {
case \'title\':
$first_name = get_post_meta( $post_id, \'booking_first_name\', true );
$last_name = get_post_meta( $post_id, \'booking_last_name\', true );
echo $first_name . \' \' . $last_name;
break;
case \'booking_email\':
$email = get_post_meta( $post_id, \'booking_email\', true );
echo $email;
break;
case \'booking_contact_phone\':
$contact_phone = get_post_meta( $post_id, \'booking_phone\', true );
echo $contact_phone;
break;
case \'booking_mobile_phone\':
$mobile_phone = get_post_meta( $post_id, \'booking_phone_mobile\', true );
echo $mobile_phone;
break;
}
}