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 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题