wordpress在新窗口打开留言者链接
為什么80%的碼農都做不了架構師?>>> ??
沒有什么技術含量可言,網上早有高手支招,但其方法在我現在使用的inove主題下不行,于是自己研究了下代碼,完美解決,分享一下:
一般主題都可以這樣修改:
1、打開wordpress目錄的下/wp-includes/comment-template.php文件。
2、找到下面這行代碼:
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’>$author</a>”;
3、在<a>標簽中添加target屬性,值為‘_blank’(在新窗口中打開鏈接),保存。即代碼修改為:
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’ target=’_blank’>$author</a>”;
此方法是適用于大部分主題,同時wp-recentcomments插件上的留言者鏈接也可以在新窗口中打開。但是有些主題就不行,包括烏幫圖博客現在使用的inove主題,,不過同樣也可以更改。
1、打開插件目錄下的functions.php文件。找到:
<?php if (get_comment_author_url()) : ?>
<a id=”commentauthor-<?php comment_ID() ?>” class=”url” href=”<?php comment_author_url() ?>” rel=”external nofollow”>
2、同樣添加 target=”_blank”,改為 <a id=”commentauthor-<?php comment_ID() ?>” class=”url” href=”<?php comment_author_url() ?>” rel=”external nofollow” target=”_blank”>,保存。
這是inove主題上的,不同主題就可能不同,其實你只需在comment.php留言相關文件或functions.php文件中搜索href=,找到get_comment_author_url()函數,修改<a>標簽即可。
ps:如果直接復制上述代碼,請注意中英文標點。
轉載于:https://my.oschina.net/myroot/blog/99651
總結
以上是生活随笔為你收集整理的wordpress在新窗口打开留言者链接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做梦梦到丧尸爆发是什么意思
- 下一篇: C#WinForm WebBrowser