当前位置: 首页 > 阿里云优惠 > 阿里云服务器优惠>> 为WordPress文章中的标签链接,添加nofollow属性 – WordPress 教程

为WordPress文章中的标签链接,添加nofollow属性 – WordPress 教程


为WordPress文章中的标签链接,添加nofollow属性 – WordPress 教程
WordPress

WordPress标签默认并无rel=”nofollow“属性。rel=”nofollow”属性的作用是:告诉搜索引擎,无需追踪目标页,禁止蜘蛛爬行和传递权重。如果你不准备让搜索收录标签,可以通过下面的代码为标签添加该属性。

将下面的代码添加到当前主题functions.php中:

function cx_tags() {    $posttags = get_the_tags();    if ($posttags) {        foreach($posttags as $tag) {            echo '<a class="tag-link' . $tag->term_id . '" href="https://xyy1.com/27346.html'.get_tag_link($tag).'" rel="nofollow">'.$tag->name.'</a>';        }    }}

用:

<?php cx_tags(); ?>

替换主题模板中标签标准函数:

<?php the_tags(); ?>

当然,你还可以在 rel=”nofollow” 后面添加 target=”_blank” 实现在新窗口或标签中打开链接。


服务器购买/咨询热线:1563700917115617636856

本文链接:http://www.sqxnmj.com/alfwq/28223.html
tags:
腾讯云服务器特惠

  • 关注微信
是否收录:

猜你喜欢

微信公众号