wordpress留言版塊的評論鏈接和昵稱鏈接如何實現新窗口打開,給wp的評論鏈接加上nofollow。
wordpress默認的是在本站打開,在WordPress評論中,會留下留言者的網址超鏈接,直接點擊就會離開當前的頁面,直接造成頁面流量丟失,從而提高了網站的跳出率。讓評論也像wp網站標題一樣新窗口打開,這一點不僅僅對seo不利,而且也不符合用戶體驗。下面我們分別來說下wordpress評論鏈接新窗口打開和加nofollow。
wordpress實現評論鏈接新窗口打開
代碼見:
找到:WP-include/comment-template.php????? 這個文件
然后在:function get_comment_author_link( $comment_ID = 0 ) {
/** @todo Only call these functions when they are needed. Include in if… else blocks */
$url??? = get_comment_author_url( $comment_ID );
$author = get_comment_author( $comment_ID );if ( empty( $url ) || ‘http://’ == $url )
$return = $author;
else
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’ >$author</a>”;
return apply_filters(‘get_comment_author_link’, $return);
}然后在找到:
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’ >$author</a>”;
return apply_filters(‘get_comment_author_link’, $return);
}加一個target=’_blank’
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’ target=’_blank’>$author</a>”;
return apply_filters(‘get_comment_author_link’, $return);
文字說明如下:
首頁打開wp-includes文件夾,找到comment-template.php文件打開。找到以下代碼:
- $return?=?“<a?href=’$url’?rel=’external?nofollow’?class=’url’>$author</a>”;
在標簽中插入一句[target="_blank"]尖括號中的內容,然后保存。這樣,訪客昵稱所指向的鏈接就會在新窗口打開了。
當然,你也可以完全不讓訪客的昵稱顯示鏈接,就是將上面這行代碼中$author前后的兩個尖括號內的內容(a標簽)直接刪除。最后代碼如下:
- $return?=?“$author”;
評論鏈接加nofollow
其實,讓訪客昵稱帶上鏈接更有利于吸引人氣。況且,我們都看到了nofollow這個屬性,就是說即使搜索引擎見到這個鏈接也不會追蹤過去,更不會傳遞權重或者PR。google和百度都支持nofollow屬性。
在默認的WordPress模板中,我們看到評論人的留言鏈接網址都是設置成rel=’external nofollow’屬性,如果你換的模板沒有了的,你加上這個就行了,就這么簡單。
評論