Artikel Verzeechnes
Déi standardméisseg Linkoptioun am WordPress Admin Panel gëtt typescherweis fir Frëndschaftslinks benotzt.
Dorënner, "Link Relatioun (XFN)" bitt Webmasteren vill Link Relatioun Optiounen, wéi: Aarbechtsplaz Relatioun, geographesch Relatioun, Famill Relatioun, emotional Relatioun ... awer dës sinn net ganz nëtzlech fir eis.
WordPress Blog Friends Chain Set Nofollow Tag
Wann Dir Affiliate Linken an externe Linken op e WordPress Blog addéiere musst, musse mir vläicht den "nofollow" Attribut op aner extern Links addéieren.
Dës méiglech Linkverhältnis ass net als Standard verfügbar, also musse mir den nofollow Tag selwer addéieren.
Fir den "nofollow" Attribut an d'Funktioun an Effekt vum rel = "noopener", wann Dir net versteet, kënnt Dir op de Link hei drënner klicken fir déi relevant Instruktiounen ze gesinn ▼
Wéi addéiere mer Nofollow Attribut zu WordPress Affiliate Links?
Füügt de folgende Code direkt un de WordPress Thema dat Dir benotztfunctions.phpdéi lescht vun der Datei ?> a späicheren ▼
/**
* WordPress友情链接添加nofollow属性标签
* https://www.chenweiliang.com/cwl-28448.html
* 添加两个钩子是为了确保代码只在links页面显示
* 如果你想了解更多load-$page action的信息,访问http://codex.wordpress.org/Adding_Administration_Menus#Page_Hook_Suffix
**/
add_action('load-link.php', 'sola_blogroll_nofollow');
add_action('load-link-add.php', 'sola_blogroll_nofollow');
function sola_blogroll_nofollow() {
//通过action add_meta_boxes创建我们需要的Meta Box
add_action('add_meta_boxes', 'sola_blogroll_add_meta_box', 1, 1);
//通过filter pre_link_rel将数据保存
add_filter('pre_link_rel', 'sola_blogroll_save_meta_box', 10, 1);
}
//创建Nofollow Meta Box
function sola_blogroll_add_meta_box() {
//翻译成中文就是,创建一个名叫Blogroll Nofollow的Meta Box,放在link页面的右侧边栏,Meta Box的结构
//由函数sola_blogroll_inner_meta_box产生
add_meta_box('sola_blogroll_nofollow_div', __('Nofollow标签'), 'sola_blogroll_inner_meta_box', 'link', 'side');
}
//输出Meta Box的HTML结构
function sola_blogroll_inner_meta_box($post) {
$bookmark = get_bookmark($post->ID, 'ARRAY_A');
if (strpos($bookmark['link_rel'], 'nofollow') !== FALSE)
$checked = ' checked="checked"';
else
$checked = '';
?>
<label for="sola_blogroll_nofollow_checkbox"><?php echo __('是否添加Nofollow标签?'); ?></label>
<input value="1" id="sola_blogroll_nofollow_checkbox" name="sola_blogroll_nofollow_checkbox"<?php echo $disabled; ?> type="checkbox"<?php echo $checked; ?> /> <?php echo $message; ?>
<?php
}
//保存用户的选择
function sola_blogroll_save_meta_box($link_rel) {
$rel = trim(str_replace('nofollow', '', $link_rel));
if ($_POST['sola_blogroll_nofollow_checkbox'])
$rel .= ' nofollow';
return trim($rel);
}Dann, op der Link Redaktioun Säit, kënnt Dir kucken ob d'Astellungsoptioun vum Nofollow Attribut Label ▼

All déi uewe genannte Methode kënne fir tatsächlech Tester benotzt ginn.
Hoffentlech ass den Artikel "Wéi kann een den Nofollow-Attribut zu WordPress Friend Links derbäisetzen? Den Nofollow-Tag fir Blog Friend Links setzen", deen um Blog vum Chen Weiliang ( https://www.chenweiliang.com/ ) gedeelt gouf, hëllefräich fir Iech.
Deelt gären de Link vun dësem Artikel: https://www.chenweiliang.com/cwl-28448.html

