我在函数中添加了以下代码。php扩展用户配置文件页面的功能,并能够添加指向作者社交媒体的链接。
function my_new_contactmethods( $contactmethods ) {
// Add Site
$contactmethods[\'mysite\'] = \'My Site\';
// Add Google Plus
$contactmethods[\'google_plus\'] = \'Google Plus\';
// Add Behance
$contactmethods[\'behance\'] = \'Behance\';
// Add Twitter
$contactmethods[\'twitter\'] = \'Twitter\';
//add Facebook
$contactmethods[\'facebook\'] = \'Facebook\';
return $contactmethods;
}
add_filter(\'user_contactmethods\',\'my_new_contactmethods\',10,1);
关于作者。php我这样称呼链接:<a title="Follow me on Twitter" href="<?php the_author_meta( \'twitter\', $author_id ); ?>"><img src="twitter.png" alt="" /></a>
<a title="Follow me on Facebook" href="<?php the_author_meta( \'facebook\', $author_id ); ?>"><img src="facebook.png" alt="" /></a>
<a title="Follow me on Behance" href="<?php the_author_meta( \'behance\', $author_id ); ?>"><img src="behance.png" alt="" /></a>
<a title="Follow me on Google+" href="<?php the_author_meta( \'google_plus\', $author_id ); ?>"><img src="google-plus.png" alt="" /></a>
这个解决方案的问题是,即使作者没有填写相应的字段,它也会显示图像和链接。这是否是一种简单的方式来回应之前填写的链接?