A-A+

刚刚找到的,特别针对neoease主题评论在新窗口打开的解决办法

本文于2017年04月08日最后更新 博客心得

没有什么技术含量可言,网上早有高手支招,但其方法在我现在使用的neoease系列主题下不行,于是我在各大网站搜索了一下,找到了,但她教的方法出现了代码错误,所以我就自己研究了一下代码,完美解决,分享一下:

一般主题都可以这样修改:

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 target=’_blank’  href=’$url’ rel=’external nofollow’ class=’url’ >$author</a>”;

此方法是适用于大部分主题,同时wp-recentcomments插件上的留言者链接也可以在新窗口中打开。但是有些主题就不行,包括张自然博客现在使用的neoease主题,,不过同样也可以更改。

1、打开插件目录下的functions.php文件。找到:

<?php if (get_comment_author_url()) : ?>
<a id=”commentauthor-<?php comment_ID() ?>” class=”url”a  target="_blank"  href=”<?php comment_author_url() ?>” rel=”external nofollow”>

2、同样添加 target=”_blank”,

改为 <a id=”commentauthor-<?php comment_ID() ?>” class=”url” a  target="_blank" href=”<?php comment_author_url() ?>” rel=”external nofollow”>,保存。

这是inove主题上的,不同主题就可能不同,其实你只需在comment.php留言相关文件或functions.php文件中搜索href=,找到get_comment_author_url()函数,修改<a>标签即可。
张自然友情提醒:如果直接复制上述代码,请注意中英文标点。

给张自然个人博客留言

Copyright © ZhangZiRan.com All Rights Reserved. 张自然个人博客 内容版权所有,同时保留所有权利。个人博客免责声明

用户登录