今天在小雨博客看到的一个插件功能,但是他那个上面没有下载地址,然后自己搜索了一下,最后放到了自己的博客上面。
我不是很喜欢插件,虽说可以在后台很方便的启动或者暂停,强迫症不能忍受,所以打开插件,可以看到以下代码,把他添加到主题目录下的functions.php文件内
function admin_xfn() {?>
<script type="text/javascript">
<!--
addLoadEvent(addNofollowTag);
function addNofollowTag() {
tables = document.getElementsByTagName('table');
for(i=0;i<tables.length;i++) {
if(tables[i].getAttribute("class") == "links-table") {
tr = tables[i].insertRow(1);
th = document.createElement('th');
th.setAttribute('scope','row');
th.appendChild(document.createTextNode('拒绝引擎追踪'));
td = document.createElement('td');
tr.appendChild(th);
label = document.createElement('label');
input = document.createElement('input');
input.setAttribute('type','checkbox');
input.setAttribute('id','nofollow');
input.setAttribute('value','nofollow');
label.appendChild(input);
label.appendChild(document.createTextNode('Nofollow'));
td.appendChild(label);
tr.appendChild(td);
input.name = 'nofollow';
input.className = 'valinp';
if (document.getElementById('link_rel').value.indexOf('nofollow') != -1) {
input.setAttribute('checked','checked');
}
return;
}
}
}
//-->
</script>
<?php
}
add_action('admin_head','admin_xfn');
然后添加或修改链接的时候效果就是这个样子的

前台链接代码是这个样子显示的
<a href="https://daliuzi.cn/" rel="nofollow" target="_blank">大刘子</a>
公益传播:因为有你,爱不罕见。
转载请注明出处:大刘子 » WordPress链接接管理添加Nofollow可选属性