dongqixian8474 2019-01-08 08:11
浏览 39
已采纳

外部链接被阻止

I have a question about my quick and dirty solution for displaying a clickable icon in my wordpress header. I just want to a a quick icon to open a external link so i add the following line to my template.php file:

<a href="<?php echo esc_url( "http://www.google.com/" ); ?>" rel="external" class="site-intro"><i class="fab fa-github-alt fa-2x"> </i></a>

I spotted the region where my header will be initiated and will be styled. The icon will be shown as I wanted it to be but I can not click the link... When I change the link to my home URL or use 'home_url' the icon is clickable. But when I use an external link I get the blocking sign when I hover over the link.

Might anyone know why this is happening?

/**
 * Site title
 * Displays the gravatar, site title and description
 * Hooked into highwind_header()
 * @since 1.0
 */
if ( ! function_exists( 'highwind_site_title' ) ) {
    function highwind_site_title() {
        ?>
        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home" class="site-intro">
            <?php
                do_action( 'highwind_site_title_link' );
                if ( apply_filters( 'highwind_header_gravatar', true ) ) {
                    echo get_avatar( apply_filters( 'highwind_header_gravatar_email', $email = esc_attr( get_option( 'admin_email' ) ) ), 256, '', esc_attr( get_bloginfo( 'name' ) ) );
                }
            ?>

            <h1 class="site-title"><?php esc_attr( bloginfo( 'name' ) ); ?></h1>
            <h2 class="site-description"><?php esc_attr( bloginfo( 'description' ) ); ?>
            </h2>
        </a>

        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">

        <a href="<?php echo esc_url( "http://www.google.com/" ); ?>" rel="external" class="site-intro"><i class="fab fa-github-alt fa-2x"></i></a>
    <?php
    }
}
  • 写回答

1条回答 默认 最新

  • dpp66953 2019-01-08 08:13
    关注

    Please change double quote to single quote.

    <?php echo esc_url( 'http://www.google.com/' ); ?>
    

    As:

    <a href="<?php echo esc_url( 'http://www.google.com/' ); ?>" rel="external" class="site-intro">
    <i class="fab fa-github-alt fa-2x"> </i>
    </a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?