为WordPress添加ajax评论

在Wordpress中使用ajax评论是很有必要的,这样可以增强用户体验。Wordpress有很多ajax评论的插件,但会增加系统负担,不是很好,下面就来介绍一个不用插件添加ajax的方法。

1、下载相关文件:comments-ajax (91)
下载解压后将comments-ajax.js和comments-ajax.php上传到你的主题的目录中。

2、在你的主题文件中编辑header.php
找到

1
<?php if (is_singular()) wp_enqueue_script('comment-reply'); ?>

替换为

1
2
3
4
<?php if (is_singular()){ ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/comments-ajax.js"></script>
<?php } ?>

然后你就可以使用ajax评论了。
原文:http://kan.willin.org/?p=1271

无觅相关文章插件,快速提升流量

本文永久链接地址: http://www.cngry.com/archives/wordpress-ajax-comment-no-plugins.html

本文短网址:http://gry.im/1350

转载请注明: 转载自gry's blog

如果你觉得本博内容不错,欢迎 [订阅 gry's blog],以便第一时间了解本博更新内容!

前一篇: 
后一篇:

共有 9 条评论

可用XHTML标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(吐) (难过) (酷) (谄笑) (调皮) (色) (脸红) (给力) (笑) (睡觉) (生病) (生气) (烧香) (淘气) (流口水) (汗) (晕) (惊恐) (微笑) (尴尬) (大笑) (困) (囧) (哭) (吃饭) (口罩) (压力) (冷) (住嘴) (书呆子) (不给力) (不)

Twitter
Feed