2012-10-18 35 views
0

我打算改变我的网站的wordpress主题。该主题允许我使用主题中提供的简码选项将边框和其他位置的社交图标添加到网站中。但是我想在开始处添加rel =“nofollow”,并在结果URL的末尾添加target =“_ blank”。如何在此wordpress简码中添加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'); 

请问任何人请告诉我如何在URL中添加nofollow和target_blank?

回答

1

此行

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

只是改变

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

谢谢版本了。它像魅力一样工作。 –

+0

不客气:-) –

相关问题