douzhan8652 2015-06-29 16:43
浏览 306
已采纳

高级自定义字段 - 添加Linkedin

I am having trouble creating a clickable Linkedin link in WordPress via Advanced Custom Fields Plugin. It was simple when I wanted to add phone number and email. But I can not figure out how to make just a Linkedin icon appear for each user as a clickable link.

Code: function member_contact() {

$vcard = get_field('vcard');
$bio   = get_field('bio_pdf');
$linkedin = get_field('linkedin');
$phone = get_field('phone');
$fax   = get_field('fax');
$email = get_field('email');

$post_info = '';

if (isset($vcard['url'])) {
    $img = get_stylesheet_directory_uri() . "/images/mail-icon.png";
    $post_info .= '<a class="vcard" href="'.$vcard['url'].'"><img src="'.$img.'" /> Download Contact</a>';
}

if (isset($bio['url']) && isset($vcard['url'])) {
    $post_info .= ' | ';
}

if (isset($bio['url'])) {
    $post_info .= '<a class="bio-pdf" href="'.$bio['url'].'">Download Bio</a>';
}

if (isset($linkedin['url']) && isset($vcard['url']) || isset($bio['url'])) {
    $post_info .= ' | ';
}

if (isset($linkedin['url'])) {
    $post_info .= '<a href="'.$linkedin['url'].'"><i class="fa fa-linkedin" style="color:blue"></i> Linkedin</a>';
}


$post_info .= '<ul class="member-contact">';
$post_info .= "<li>$email</li>";
$post_info .= "<li>p: $phone</li>";
$post_info .= "<li>f: $fax</li>";
$post_info .= "</ul>";
var_dump($linkedin);

Code from a user's repo (Kevinlearynet),which I am not sure how to integrate

                <?php if ( $linkedin = get_field('team_linkedin') ): ?>
                <a href="<?php echo $linkedin; ?>"><i class="icon-linkedin"></i></a>
                <?php endif; ?>

Dump for $linkedin

string(21) "https://www.yahoo.com"

Pictures: enter image description here

  • 写回答

2条回答 默认 最新

  • doutui7955 2015-06-29 16:59
    关注

    You can edit your code like this to integrate the linkedin link.

    function member_contact() {
    
            $vcard = get_field('vcard');
            $bio   = get_field('bio_pdf');
            $phone = get_field('phone');
            $fax   = get_field('fax');
            $linkedin = get_field('linkedin');
            $email = get_field('email');
    
            $post_info = '';
    
            if (isset($vcard['url'])) {
                $img = get_stylesheet_directory_uri() . "/images/mail-icon.png";
                $post_info .= '<a class="vcard" href="'.$vcard['url'].'"><img src="'.$img.'" /> Download Contact</a>';
            }
    
            if (isset($bio['url']) && isset($vcard['url'])) {
                $post_info .= ' | ';
            }
    
            if (isset($bio['url'])) {
                $post_info .= '<a class="bio-pdf" href="'.$bio['url'].'">Download Bio</a>';
            }
    
            $post_info .= '<ul class="member-contact">';
            $post_info .= "<li>$email</li>";
            $post_info .= "<li>p: $phone</li>";
            $post_info .= '<a href="$linkedin"><i class="icon-linkedin"></i></a>';
            $post_info .= "<li>f: $fax</li>";
            $post_info .= "</ul>";
    
            genesis_markup( array(
                'html5' => sprintf( '<div class="entry-meta">%s</div>', $post_info ),
                'xhtml' => sprintf( '<div class="post-info">%s</div>', $post_info ),
            ) );
    
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)