wordpress在新窗口打开留言者链接

社会主义新天地 提交于 2020-02-29 02:53:16

没有什么技术含量可言,网上早有高手支招,但其方法在我现在使用的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:如果直接复制上述代码,请注意中英文标点。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!