WordPress ajax comments inline plugin

作者 FarLee 2011年3月25日 9:48:13   ‖浏览(190,993)

This plugin displays ajax comments inline when one of the comment-popoup-link of your wordpress blog posts is clicked, you can click to show or hide the inline ajax comments (Show comment form if no comment reply yet),Show it directly in your wordpress blog’s home/main page,category page or tag page (index.php/archive.php).This makes users view or post comment reply more easily.
Wordpress inline ajax comments

Download:  WordPress ajax comments inline

Features

Show/Hide ajax comments inline

Click the “Show comments” link of one post in your wordpress blog’s home page(or category,tag archive page etc.) ,then the inline ajax comments for this post would be displayed below.This plugin uses jQuery ajax to get the comments from server,so only the comments area would be refresh, save bandwidth and make your wordpress blog be loaded much faster.After that,you have a choice to collapse the ajax comments by clicking the “Hide Comment” link.

The comment form would be displayed inline if there is no comment yet. So the users could post comments directly for each post in the home page or category/tag/archive page etc, do not need to get into the single article page to post reply comments.Also the comment form could be collapsed.

Availabe to set Comment order and Comment number

In the WordPress Ajax Comments Inline Options admin page, you can choose how many comments to be displayed in the inline ajax comment field, set the new or old comments displayed first.

Choose to use Google jQuery CDN or not

This plugin requires the most popular jQuery javascript framework,it loads Google jQuery CDN (content delivery network) by default. There are many advantages for serve jQuery from Google hosted api CDN, such as user browser cache,reduce server bandwidth request, decreased latency, increased parallelism and better caching,which decribed by Dave Ward.

However,for some reason, you could choose to load jQuery from your wordpress blog’s own jQuery libraries. To fit your preference,just set the option of Inline Ajax Comments plugin in the dashboard admin page.

Demo && Testing

Click here for demo & testing

Note: I have disabled the comment function in the demo blog as there are so many spams :(.There will be a comment form when you click “leave a comment” if the comments of the post are open.

Installation

  • Upload WordPress Ajax Comments Inline plugin to your wordpress blog’s `/wp-content/plugins/` directory.
  • Activate the plugin through the ‘Plugins’ menu in WordPress Dashboard.
  • Place <?php show_hide_comments_link(); ?> in your theme’s template file where you want the “Show Comments” / “Hide Comments” link to be displayed.
  • Place  <?php display_ajax_comments(); ?> in your theme’s template file where you want the ajax comment field (or comment form) to be displayed.
  • You can place the short code above in your theme’s index.php (or home.php,front-page.php:  display inline ajax comments in wordpress blog’s home page), or archive.php(category.php,tag.php,date.php etc:  display inline ajax comments in the category or tag page…).Take a look at the example bellow for details.
  • If the css style doesn’t suit for your theme, you can modify the file wp-ajax-comments-inline/wpaci_style.css in the plugin directory to custimize how it looks.
  • Go to the admin page: *Dashboard-Plugins-Inline Ajax Comments* to set the settings if you don’t want the default one.

Example 1: modified index.php

<?php while ( have_posts() ) : the_post(); ?>
    .....
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="entry-meta"></div><!-- .entry-meta -->
        <div class="entry-content"></div><!-- .entry-content -->
        <div class="entry-utility">
           <span><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
 <?php show_hide_comments_link(); ?>
        </div><!-- .entry-utility -->
 <?php display_ajax_comments(); ?>
    </div><!-- #post-## -->
<?php endwhile; // End the loop. Whew. ?>

Example 2: modified loop.php

<?php if(comments_open()) : ?>
    <p>
        <?php comments_popup_link(__('Leave a comment?','wapi') , __('1 comment','wapi') , __('% comments on ','wapi') .get_the_title(), 'comments-link', __('Comments are closed for this post','wapi') ); ?>
        <?php show_hide_comments_link(); ?>
    </p>
    <?php display_ajax_comments(); ?>
<?php endif; ?>

Best Practice: Search the default wordpress comment link display funtion: comments_popup_link, place <?php show_hide_comments_link(); ?> after it outside the html tag  “<span>…</span>” which surround it, or replace the whole <?php comments_popup_link(.......; ?> whith <?php show_hide_comments_link(); ?>.

Then search </div> or </p> from this position below, place <?php display_ajax_comments(); ?> just after the first found </div> or </p> tag.

Note: The short code must be placed in the loop, as in this example, put it between <?php while ( have_posts() ) : the_post(); ?> and <?php endwhile; // End the loop. Whew. ?> .

WordPress ajax comments inline FAQ

Could I replace my wordpress themes’ default comments-popup link?->Of course you can. Just replace
<span><?php comments_popup_link(....)?></span>with <?php show_hide_comments_link(); ?>.

Where to display the php code? -> Look at the example above.

Uninstallation

Remember to comment out (or remove) the php template tag code in the theme file before you disable the WordPress Ajax Comments Inline Plugin:

<?php // show_hide_comments_link(); ?></div><?php /display_ajax_comments(); ?>

Change log
= 1.1 = Update

  • Fix bug: Fix the bug when the code is placed at the none main page(category page etc.),the error `Failed to get comments:error` occur.
  • New feature added: Add comment form in the bottom of ajax comments field if the posts already have comment.So the comment form could be clicked to display whether the post has comments or not.

= 1.0 =
This is the first version of WordPress ajax comments inline plugin, please reply to report bug here if you found.

“WordPress ajax comments inline plugin”文章评论(132)

  1. How can I also add comment form if the posts already have comment?
    I’d be appreciated if you make it a feature :D

    • Good advice,this feature would be considered in the next version of WordPress ajax comments inline plugin.

    • naza

      lets try this

      • kakarot

        trying

  2. Cool

    But it’s only work with default permalink.
    I have “Failed to get comments:error” with custom permalink (/blog/%postname%/).
    How can i do to get it work ?

    Answer please ^^ your plugin is very cool, simple and light. It’s just what i want !

    • Hi,could you give more details about your problem? It works in my blog with my custom permalink (/archives/%postname%.html). eg: give your blog url or where you placed the code < ?php show_hide_comments_link(); ?> and < ?php display_ajax_comments(); ?>.

      • Florent

        Hi !
        I’ve resolved the problem, thanks for this great plugin !
        Firstly the update was not working with my permalink : i’ve had the same problem that with the 1.0 version.
        Finally i found the problem : I have a static front page on my site, the blog is another one page.
        I’ve reactivate the default blog page, and the plugin works great.
        Then, I’ve reactivate my own static front page… and it works too -__-’ haha !
        so, everything is working well !
        I hope it will serve you !

        Thank you again for this plugin !

      • Monzu

        Hello FarLee,

        I get error when i clieck ” Leave a Reply ”

        Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 95

        Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/politilist/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 96

        Thank you
        M

    • aaa

      aad

    • some conetn

  3. Florent

    Here my blog where you can see the problem.
    http://www.les-deux-flos.com/blog/
    There’s no modification on your original plugin.
    I’m sorry, i’m not a programmer, so i can’t really identify the problem !

    hope it will help you.

    (sorry for my english, i’m french ^^)

    • Hi,your blog url is broken now.

  4. Florent

    The part of my loop :
    tinypaste.com/f8799
    I use twentyten theme.

  5. is this an ajax post?

    • please ignore the previous comment…

      • aha, it’s without ajax post, as I think ajax post will not lead visitor to the single article page, which results your site visitor doesn’t have the chance to view your article details,and reduces your site page view.However, I would consider to add this feature as an option to the WordPress Ajax Comment Inline (waci) plugin when the new version is updated, maybe this weekend. :)

        • please please please add ajax post!!!

          • just checking…

            • dfs

              just checking too

            • jus testing

  6. Hi,

    Love the plugin! Would you consider adding support for the new WordPress 2.7+ comment features (basically, the new wp_list_comments() function) to allow for inline nested comments and replies? I’ve just been trying to adjust that myself but my programming skills are shaky…

    Cheers,
    Vince

  7. Fabio Hideo

    Hello, there!
    First of all, congratulations for this plugin. It’s all I ever wanted. Simple, usefull, and fast. Thank you very much!!!

    Wondering if there is a way to make the comments always open by default. In a “no comments” post it should be the link to display/hide the comment form…

    Again, thank you very very much!!!!!

  8. features (basically, the new wp_list_comments() function) to allow for inline nested comments and replies? I’ve just been trying to adjust that myself but my programming skills are shaky

  9. 雷锋

    雷锋

  10. Hello,
    nice plugin. I was a little surprised to see that commenting redirected automatically the visitor to the post but I can understand your reason. It’s just strange because I think people will install the plugin to reduce the circulation into the blog. It could be nice to have an option to stay on the page where the comment is created.

    • I agree. It would be very nice if the comment form submission was AJAX also, so the user stayed on the home page when they submitted.
      Thanks for the great plugin!

    • naza

      es una poronga esto! chino puto

  11. Is There a way to change the wording of the comment links without changing your code in the plugin php? For instance I don’t want it to say ‘Comment Shortcut’ I just want it to say ‘Comment’. And I’d like to remove the ‘|’ before the word comment. I’d rather not have to edit your plugin code though because I’ll always have to do that everything you make updates and rather not for something so minor. thanks!

  12. A little test.

  13. Thank you For the post its very intresting

  14. Peter

    Hi there. Where should I insert this into my php? I honestly can’t get it to work.
    Here is a copy of my index php file:
    http://www.snapoftheshutter.com/random/test-page/

    • Hi, Peter, You can replace < ?php comments_popup_link( __( ‘Leave a comment’ ), __( ’1 Comment’ ), __( ‘% Comments’) ) ?> </div> with < ?php show_hide_comments_link(); ?> </div> < ?php display_ajax_comments(); ?>

  15. Jason

    This does not seem to be working with 3.1.3. Your instructions say to install into index.php, but actually I think it needs to go into loop.php. I tried that but nothing shows up. Any help would be appreciated.

    • Jason

      Nevermind, I got it to work. It seems there is similar text 2 times in the code, and you need to paste this in the second set.

  16. Jason

    Is there a way to keep the user on the home page, if that is where they filled out the comment at?

    • Hi,Jason,Do you mean ajax posting in the home page? I am considering to update this feature in the next version.

      • Jason

        Yes. I wanted the inline comments, so people can make comments quickly. I look forward to the next version and I hope you include.

      • Jason

        Also, a feature of having the comments already expanded, would be nice. Is there a way to customize that currently?

        • yes, i would like to find a way for the comments to be expanded by default! help??

  17. Phil

    I too would like to have this installed, currently I have a static page on my homepage, but my goal is to have my blos posts show up on the homepage with comments being featured aswel. So people can comment from the home page. Similar to Jason question. Would it work on this theme? buikspierentrainenx.nl

  18. testing

    testing comment

    • Monzu

      Hello
      I get error when i clieck ” Leave a Reply ”

      Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 95

      Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/politilist/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 96

      Thank you
      M

  19. testing

    tttttttttttttttttttttttttttttt

  20. pedrao

    testando aqui do brasil

  21. I’m having trouble with this. I have version 1.1 installed and get the error, Failed to get comments: error. People are able to leave comments, they just aren’t displaying. Site is: http://www.pobkephotography.com/blog.

    What could be causing this? I checked the my code is correct.
    Thank you.

  22. Link View does not work, let’s say if we restrict the display of the 10 comments.. please help!
    Thanks.

    By the way the script is excellent!

  23. pedrao

    nao sei se funciona

  24. Is running or not!??

  25. Me

    Testing.

    • thread ed

      thread ed’s comment

  26. Carlos

    Hi, I love this plugin. But I’m trying to use it, for a little different use.

    I want to add it, on each single page/post with comments. And that it show, for example, 20 comments, and each time you click on “View” it loading the next 20 comments.

    Would it be a total different plugin or it’s something that this one can do with small changes?

    I would love the plugin to have this “feature” Hope you can consider making this as an optional :)

    Thanks a lot.

  27. Tiago

    teste

  28. FAF

    DFHFDHDH

  29. FAF

    TESTNG

  30. aaa

    aaa

  31. test

  32. Monzu

    Hello
    I get error when i clieck ” Leave a Reply ”

    Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 95

    Notice: Undefined variable: req in /home/xxxx/public_html/xxxx/politilist/wp-content/plugins/wordpress-ajax-comments-inline/ajax-comments-inline.php on line 96

    Thank you
    M

  33. 您好,在使用你的这个插件时遇到一个问题,就是我把语句放到了我的主题首页index.php,要怎么实现点击展开评论框后可以ajax评论,而不刷新页面。希邮件联系回复。非常感谢

  34. Hello! edkedkd interesting edkedkd site! I’m really like it! Very, very edkedkd good!

  35. dasdasdsad

    test asdasda

  36. Hi Far,
    as first thing I want to express my admiration for your work. The plugin seems very useful, but I don’t reach in using all his functions.
    I’ve put the code into my index.php file, and the form appears correctly, so that people can add comments also in the home page, from the link “visualizza i commenti” under the title of each article.

    But I’m not able to show in the same manner the comments that already are in the article. What I would it’s a link that allow you to add a comment (and this one already work great), and an other one that make the comments appear in the position that I want (I think I will put it under each article): my purpose it’s to make every article commentable not leaving the home page, like in Facebook.

    Is this possible? Can you gently help me?
    In this moment the comments in my site are showed by this code:

    Thank you! : )

    • Hi,Sergio. The plugin have the feature of showing the comments already posted in the article as you described. If the error “Failed to get comments:error” occured, pls confirm that the code “< ?php display_ajax_comments(); ?>” has been placed in your theme’s template file too. And try to reinstall the plugin.

    • Please check the demo.http://farlee.info/t/

  37. Hi Far,
    thank you for your help.
    I placed the code in my index.php theme file, and I tried it in many positions obtaining the same result.
    Do I have to put some code into the parentheses? I also tried to put there the permalink ‘/%year%/%monthnum%/%day%/%postname%/#comments’, but nothing changed.

  38. Wow, don’t give attention at my last reply: I fixed the problem!
    I reinstalled the plugin, but apparently nothing happened. Then I repaired permissions of my site from the admin control panel of my web hosting (Aruba), and magically the plugin worked!

    Thank you very much for your help and for your work on this plugin: I will make a donation and I invite everyone who use your code to follow my example! ;)

    • Glad to hear that this plugin can help you something.

  39. sd’lf’sdla’flasd’fl’asd

  40. Іt’s an remarkable article for all the internet people; they will obtain benefit from it I am sure.

  41. test

    TEST123

  42. Hello to every body, it’s my first pay a visit of this webpage; this weblog includes amazing and really excellent material in favor of visitors.

  43. Hi, just wanted to mention, I liked this post.
    It was inspiring. Keep on posting!

  44. For newest news you have to go to see internet and on the web
    I found this web page as a best web site for most up-to-date updates.

  45. Hi there, just wanted to say, I loved this blog post. It was inspiring. Keep on posting!

  46. We’re a bunch of volunteers and opening a brand new scheme in our community.
    Your website offered us with helpful info to work on.
    You have performed an impressive activity and our
    whole group can be grateful to you.

  47. Hi my friend! I want to say that this post is amazing,
    nice written and come with almost all significant infos.
    I’d like to see more posts like this .

  48. Excellent website you have here but I was wanting to know if you knew
    of any discussion boards that cover the same topics discussed here?
    I’d really love to be a part of community where I can get comments from other
    experienced individuals that share the same interest.
    If you have any suggestions, please let me know.
    Bless you!

  49. However it is important to realize that the Fat Loss Factor is not a panacea that will magically remove any fat
    and If you are looking for a “lose 10 pounds in 10 days magical programs”, then The Fat Loss Factor is probably not for you.
    It does not care where you live, but it certainly does
    seem to thrive on the way you live. But let me explain
    the whole concept of this diet program.

Trackbacks/Pingbacks

  1. 信用卡购买 linode vps,过期未续费中 – 远方博客
  2. WordPress ajax comments inline plugin | 我是小鱼

来说兩句