WordPress添加用户个人资料选项
在主题function.php里添加以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 | // 联系信息中添加作者信息字段 add_filter('user_contactmethods', 'boke112_user_contact'); function boke112_user_contact($user_contactmethods){ unset($user_contactmethods['aim']); unset($user_contactmethods['yim']); unset($user_contactmethods['jabber']); $user_contactmethods['qq'] = 'QQ'; $user_contactmethods['weixin'] = '微信号'; $user_contactmethods['weibo'] = '新浪微博'; $user_contactmethods['toutiao'] = '头条号'; $user_contactmethods['zanshang'] = '赞赏作者'; return $user_contactmethods; } |
1 2 3 4 5 6 | <?php //直接输出QQ字段的值 the_author_meta( 'qq' ); //这个也是输出QQ字段的值 echo get_the_author_meta( 'qq' ); ?> |
1 2 3 | <?php if ( get_the_author_meta( 'qq' ) ){ echo '作者QQ:'.get_the_author_meta( 'qq' ); }?> |