【问题标题】:How to add rel="nofollow" and target="_blank" in this wordpress shortcode?如何在这个 wordpress 简码中添加 rel="nofollow" 和 target="_blank"?
【发布时间】:2012-10-18 11:37:48
【问题描述】:

我打算更改我网站的 wordpress 主题。该主题允许我使用主题中提供的简码选项在侧边栏和网站的其他位置添加社交图标。但我想在结果 URL 的开头添加 rel="nofollow" 和 target="_blank"。

这是我在其中一个主题文件中找到的代码。

// [social_icon src="" title="Add a hover title!" link="#custom-link"]
function social_icon_sc($atts, $content = null) {
    extract(shortcode_atts(array(
        'src' => 'picons33.png',
        'title' => __('Get in touch'),
        'link' => '#'
    ), $atts));

    $output = "";

    $output .= "<a href='".$link."' class='social-icon' title='".$title."'>";
    $output .= "<img src='" . get_template_directory_uri() . "/images/social_icons/".$src."' alt='".$title."' />";
    $output .= "</a>";

    return $output;
}
add_shortcode('social_icon', 'social_icon_sc');

谁能告诉我如何在网址中添加nofollow和target_blank??

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    只要改变这一行

    $output .= "<a href='".$link."' class='social-icon' title='".$title."'>";
    

    $output .= "<a rel='nofollow' href='".$link."' class='social-icon' title='".$title."' target='_blank'>";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-26
      • 2019-02-15
      • 2012-11-30
      • 1970-01-01
      • 2020-02-28
      • 2023-04-03
      • 1970-01-01
      • 2021-01-08
      相关资源
      最近更新 更多