Php WordPress链接到未链接的社交图标

Php WordPress链接到未链接的社交图标,php,wordpress,buddypress,Php,Wordpress,Buddypress,我正在尝试使用我在此处找到的一段代码向BuddyPress站点添加社交关注图标: 我按照建议的思路,将代码添加到我的plugins目录中的一个bp-custom.php文件中,图标显示在应该显示的位置,但社交档案的链接显示为文本,当我单击链接时,它返回404页面 我肯定我有什么不对劲,但我只是太无知了,没法发现 <?php //Social Media Icons based on the profile user info function member_social_extend()

我正在尝试使用我在此处找到的一段代码向BuddyPress站点添加社交关注图标:

我按照建议的思路,将代码添加到我的plugins目录中的一个bp-custom.php文件中,图标显示在应该显示的位置,但社交档案的链接显示为文本,当我单击链接时,它返回404页面

我肯定我有什么不对劲,但我只是太无知了,没法发现

<?php
//Social Media Icons based on the profile user info
function member_social_extend(){
    $dmember_id = $bp->displayed_user->id;
    $fb_info = xprofile_get_field_data('facebook', $dmember_id);
    $google_info = xprofile_get_field_data('googleplus', $dmember_id);
    $linkedin_info = xprofile_get_field_data('linkedin', $dmember_id);
    $twitter_info = xprofile_get_field_data('twitter', $dmember_id);
    echo '<div class="member-social">';
    if($fb_info||$google_info||$linkedin_info||$twitter_info){
        echo 'My Social: ';
    }

    if ($fb_info) {
    ?>
    <span class="fb-info"><a href="https://www.facebook.com/<?php echo $fb_info; ?>"  title="My Facebook" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/facebook.png" /></a></span>
<?php
}
    ?>
    <?php
    if ($google_info) {
    ?>
    <span class="google-info"><a href="https://profiles.google.com/<?php echo $google_info; ?>" title="My Googleplus" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/googleplus.png" /></a></span>
<?php
}
    ?>
    <?php
    if ($linkedin_info) {
    ?>
    <span class="linkedin-info"><a href="https://www.linkedin.com/<?php echo $linkedin_info; ?>" title="My LinkedIn" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/linkedin.png" /></a></span>
<?php
}
    ?>
    <?php
    if ($twitter_info) {
    ?>
    <span class="twitter-info"><a href="https://twitter.com/<?php echo $twitter_info; ?>" title="My Twitter" target="_blank" class="twitter-follow-button""><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/twitter.png" /></a></span>
<?php
}
echo '</div>';
}
add_filter( 'bp_before_member_header_meta', 'member_social_extend' );
?>
谢谢

看起来xprofile\u get\u field\u数据创建了自己的标记,所以您不必像在那里那样写出标记。请尝试以下方法:

$fb_info = xprofile_get_field_data(
    '<img src="' . bloginfo('wpurl') . '/wp-content/themes/family-openstrap-child/images/facebook.png" />',
    $dmember_id
);
...
<span class="fb-info"><?php echo $fb_info; ?></span>

你能给我一个404的网址吗?是的,在这里。这部分解决了我的问题,链接现在至少正确地解决了。你知道为什么我在那里看到的是文本而不是链接到社交媒体网站的图标吗?我猜这只是关于xprofile\u get\u field\u数据的行为。几年前我曾与BuddyPress合作过,并记得文档非常稀少,因此这可能对我很有帮助:-/
$fb_info = xprofile_get_field_data('Facebook', $dmember_id);