具有此功能,成员电子邮件echo返回未定义的索引。我如何以正确的方式设置这个?
function team_custom_columns( $column ) {
global $post;
switch ( $column )
{
case 'member_email':
$custom = get_post_custom();
echo $custom['member_email_address'][0];
break;
case 'member_description':
the_content();
break;
}
}
答案 0 :(得分:1)
使用三元运算符:
echo isset($custom['member_email_address'][0])
? $custom['member_email_address'][0]
: 'not set';
或者如果:
if (isset($custom['member_email_address'][0])) {
// value exists
} else {
// not set
}
答案 1 :(得分:0)
您可以在echo custom post index
之前使用!empty()方法function team_custom_columns( $column ) {
global $post;
switch ( $column )
{
case 'member_email':
$custom = get_post_custom();
if(!empty($custom['member_email_address'][0]))
echo $custom['member_email_address'][0];
break;
case 'member_description':
the_content();
break;
}
}