为了防止任何人(就像我一样)遇到此线程,您可以扩展此线程以显示自定义字段。
将此添加到主题functions.php
:
// Extend user profile
// CUSTOM USER PROFILE FIELDS
function my_custom_userfields( $contactmethods ) {
// ADD CONTACT CUSTOM FIELDS
$contactmethods[\'contact_phone_office\'] = \'Office Phone\';
$contactmethods[\'contact_phone_mobile\'] = \'Mobile Phone\';
// ADD ADDRESS CUSTOM FIELDS
$contactmethods[\'address_line_1\'] = \'Address Line 1\';
$contactmethods[\'address_line_2\'] = \'Address Line 2 (optional)\';
$contactmethods[\'address_city\'] = \'City\';
$contactmethods[\'address_state\'] = \'State\';
$contactmethods[\'address_postcode\'] = \'Postcode\';
// ADD SOCIAL CUSTOM FIELDS
$contactmethods[\'contact_twitter\'] = \'Twitter\';
$contactmethods[\'contact_facebook\'] = \'Facebook\';
$contactmethods[\'contact_linkedin\'] = \'LinkedIn\';
return $contactmethods;
}
add_filter(\'user_contactmethods\',\'my_custom_userfields\',10,1);
然后只需在
foreach
打电话,比如:
echo \'<li>\'. get_avatar($user->ID, 120) .\'<br />\'. $user->display_name .\'<br /><a href="mailto:\'. $user->user_email .\'">\'. $user->user_email .\'</a><br />\'. get_user_meta($user->ID, \'description\', true) .\'<br />\'. get_user_meta($user->ID, \'contact_twitter\', true) .\' - \'. get_user_meta($user->ID, \'contact_facebook\', true) .\' - \'. get_user_meta($user->ID, \'contact_linkedin\', true) .\'</li>\';
我希望这是可以张贴在这里。这有点离题,但希望能有所帮助(如果不是mods,请删除)。