Yet another Ajax paged comments plugin for wordpress (YAAPC)

This Plugin provides Ajax enabled comments system with paging,posting and form validation to your WordPress blog.

image

Features:

  • Ajax page navigation

    When the user navigate through the comments via page selector,only the comments area will be send back to the client and refreshed,not the full page.This actually save your server load and bandwidth thus making your blog faster and more responsive. The paging system works even if JavaScript is disabled.

  • SEO friendly

    Pagination can cause a duplicate content issue with search engines.YAAPC can automatically generate “noindex,follow” meta tag in your paged comments page to avoid duplicate content in search engines that may hurt your rankings.(many thanks for Hank’s great comment and advice)

  • Ajax comment posting

    Posting comments via Ajax,without page refreshing.

  • Comment form validation

    validate the user input in comment form before sending to server. 

Download Yet another AJAX paged comments plugin for wordpress(YAAPC)

Demo and Testing

Click here for demo and testing.

please don’t comment to this post for testing purposes.

Installation

  1. Upload YAAPC to the `/wp-content/plugins/` directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. (Optional,but recommended) Modify your comments template(comments.php),add a div with id="yaapc-comments" to wrap the comment list area. Place <?php yaapc_pages()?> in where you want the page selector to show.take a look at the example bellow for details.
  4. Modify the style.css in YAAPC directory to custimize how YAAPC looks .

An example of a modified comments.php:

... ...
<!-- You can start editing here. -->
<div id="yaapc-comments">
<?php if ($comments) : ?>
	<h3 id="comments"><?php the_title();</h3>
	<?php yaapc_pages()?>
	<ol   class="commentlist">
	<?php foreach ($comments as $comment) : ?>
	... ...
	<?php endforeach; /* end for each comment */ ?>
	</ol>
	<?php yaapc_pages()?>
 <?php else : // this is displayed if there are no comments so far ?>
	<?php if ('open' == $post->comment_status) : ?>
		<!-- If comments are open, but there are no comments. -->
	 <?php else : // comments are closed ?>
		<!-- If comments are closed. -->
		<p class="nocomments">Comments are closed.</p>
	<?php endif; ?>
<?php endif; ?>
</div>
... ...

Administration UI

click for full image:

image

Q&A

  • How to display the comment number?

    Add <?php echo $comment->yaapc_number;?> to your comment template(inside loop).

158 thoughts on “Yet another Ajax paged comments plugin for wordpress (YAAPC)”

  1. 发表评论后没有清空,需要清空一下吗?光标跳到我的留言处,能否自定义留言显示顺序,顺序还是倒序。

  2. Isn’t that causeing a lot of duplicate content? Do i’ve to stop all “?p=x&cp=x#comments” pages from being indexed via .htaccess/robot.txt or is there a switch to mark them “noindex” in robots meta tag? Every click on another comments page is counted as real pageview, right?

  3. Ok, weird issue. I’m using the following plugin to page comments.

    http://wordpress.org/extend/plugins/yaapc/

    Using the following code within the comments.php to produce a comment number for each comment (unique to each post):

    then

    And the following to display the comment number (inside loop)

    The issue is that with each page of comments, it resets the counter. So on page 1 you’re have comments numbered 1-5, then on the next page comments again are numbered 1-5, etc…

    A link the issue:

    http://www.canigetaverdict2.com/2008/09/03/vertigo-a-life/

    Any thoughts? A better way to get a unique comment number?

  4. Dean,

    Thanks, but that didn’t work. Right now I’m using

    $startpage = ($_GET[“cp”] – 1) * 5;

    then

    ?php $i = $startpage;

    posting with

    echo $i;

    It’s a work around and a little sloppy, but works.

    echo $comment->yaapc_number; didn’t work for some reason.

    Any thoughts?

  5. Dean,

    Yes. Using 1.1.4. Odd.

    I am not, however, using the “Optional, But Recommended” code in my comments.php. Would that impact it.

    Thanks again.

  6. Hi,

    I’ve been looking for something like this for a long time now. This does everything I want thankyou very much, I hope it will work on my blog.

    The only additions I would reccomend:
    – A fade in/fade out when you naviagte through the pages, so it doesn’t collapse and expand when you change page also.

    – A show all button which when clicked shows all the comments.

    Then you could have it so that the search engine can retrieve the information from all the comments, because afaik it is only getting the data from the first 5 comments atm.

  7. Pingback: Allelujah !
  8. Dean,

    Enjoying your plugin, however people visiting the site are having issues when using Firefox. It looks like a permalinks issue.

    When Firefox users navigate away from the default page, there is a problem.

    For example (pardon the off color material. Customers are satirists):

    http://www.canigetaverdict2.com/2008/10/dear-fat-whore/

    defaults to the last page of comments. But when users of Firefox click another page of comments, a blank page with a link at the top is displayed:

    BoldItalicLinkBlockquote

    When I hover over a page number, it show’s a permalink of (for example, page 4):

    http://www.canigetaverdict2.com/?p-314&cp=4#comments

    Is this a permalinks issue with me?

    Appreciated. Again, everyone who can use it loves the plug in.

    Thanks!!!

    Jim

  9. Excellent plugin, thank you very much!

    I have 2 suggestions though (if I may):

    1. What about a “show all comments”-button, where the visitor has the possibility to display all comments?

    2. When I click on a comments-page number, the page scrolls automatically, so that the page-menu is in the middle of the browser-window. This is somewhat annoying.

    Is there a way to implement/change this?

    Thanks,
    Eddie

  10. Have you heard of any sort of issue with this Plugin and custom fields working on a page? I’ve activated this Plugin, and everything works well, but the custom fields that I am calling on the page no longer show. The interesting part is that using the_meta to list all custom fields still works.

    Any ideas? I’d really like to use this Plugin, but I won’t be able to with this issue.

  11. Hi there,

    I definetely love this plugin, but I’m experiencing a problem together with the slickr-gallery plugin. I get 4 javascript errors on my gallery page when YAAPC is activated and the gallery doesn’t get loaded, and then when I deactivate it the problem is gone and my gallery loads correctly.

    Anybody experiencing the same problem?

  12. Thanks for the great plugin!

    You might have an answer to the problem. The plugin does not seem to work on archive.php. I´ve enabled commenting with the &withcomment=1. Comments are shown, but the paginating and the ajax thingy wont work. However, i´ve cloned the archive.php code on single.php and the plugin works great.

    I´ve found so far that the wordpress core is involved, but i dont have the tools to work around it.

    Also, if you know a way not to redirect into single.php when post is submitted I would be delighted.

    My site: pubivisa – pubivisat – tietovisa – tietovisat

  13. ok, i have few stuff,

    1- will this plugin will be upgraded to work with 2.7.

    2- i have 2.6.5 installed and when ever i post a comment and it shows the refresh button, in google chrome, it freze and shows this error:

    ((big blue page:

    Aw, snap!
    Something went wrong while tring to load the page. to continue please reload the page or go to another page. ))

    3- the Previous , next buttons are at the left, how can i make it to show them in the middle.

    Thanks and keep up the good work.

  14. looks like the person is dead or something like that, but it was extremely wonderful plugin, and was eating very low memory.

  15. NOT WORKING for me.

    first page loads ok but after i press a different page or :”back” it loads the page and then reloads the site as blank page…

    very disappointing, i really wanted to use it.

  16. Well, finally I have upgraded Spaniards.es to Drupal 6 and so I have done with my ajax comment solution.
    It works fine after a few teaks. The major changes are on the menu module, since the way to register new entry points (URL paths) has changed. Then I did one minor fix on the javascript code and voilá… ajax comments working again :)
    Let’s see if I can find some time to republish the code, better explained. Maybe I should put this on a module, although I have seen some new ajax comments recently.

  17. Is this plugin working correctly for the latest version of wordpress
    it seems fantastic but i’m unable to get this working :-(

  18. trree dekjrdoiew vew iuore ui  ruirwe yur  ruire iur er euire
    erjer jkr hjgjhg ejh grehj ejge dfjkdfhj ghj gdndh dsh dfs

  19. trree dekjrdoiew vew iuore ui  ruirwe yur  ruire iur er euire
    erjer jkr hjgjhg ejh grehj ejge dfjkdfhj ghj gdndh dsh dfs – nhjjh hjhjol kui yuy rerert  yty uyuyiui

  20. what a beautiful plugin…this is what i've been looking for but I can't get it to work for WP 2.9.1 :(
    Can you please update your plugin to make it work with latest version of wordpress?

  21. Hello thumbnails do not appear on my blog, where only in the single.php file are displayed as thumbnails and comments. I've been studying the code, and I believe it is in this line.

    add_action ('template_redirect', array (& $ this, 'template_redirect'), 15);

    The link of the thumbnail image is not loaded.
     

  22. I’ve been looking around http://www.deanlee.cn and really am impressed by the terrific content here. I work the nightshift at my job and it is so boring. I have been coming here for the previous couple nights and reading. I just needed to let you know that I’ve been enjoying what I’ve seen and I look ahead to reading more.

  23. Failed opening 'editable/ads/post.php' … in wp-content\plugins\yaapc\yaapc.php(60) : eval()'d code on line 66
    also for post-top.php
    It's strange. File:  ./editable/ads/post.php exists

    Not working for me :(

  24.  
    Hello i have the twentyten template, and im not capable to make it work.
    Can you please help me?
     
    Original file
    <?php
    /**
     * The template for displaying Comments.
     *
     * The area of the page that contains both current comments
     * and the comment form.  The actual display of comments is
     * handled by a callback to twentyten_comment which is
     * located in the functions.php file.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    ?>
     
    <div id="comments">
    <?php if ( post_password_required() ) : ?>
    <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></p>
    </div><!– #comments –>
    <?php
    /* Stop the rest of comments.php from being processed,
    * but don't kill the script entirely — we still have
    * to fully load the template.
    */
    return;
    endif;
    ?>
     
    <?php
    // You can start editing here — including this comment!
    ?>
     
    <?php if ( have_comments() ) : ?>
    <h3 id="comments-title"><?php
    printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
    number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' );
    ?></h3>
     
    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
    <div class="navigation">
    <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
    <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    </div> <!– .navigation –>
    <?php endif; // check for comment navigation ?>
     
    <ol class="commentlist">
    <?php
    /* Loop through and list the comments. Tell wp_list_comments()
    * to use twentyten_comment() to format the comments.
    * If you want to overload this in a child theme then you can
    * define twentyten_comment() and that will be used instead.
    * See twentyten_comment() in twentyten/functions.php for more.
    */
    wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
    ?>
    </ol>
     
    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
    <div class="navigation">
    <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
    <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    </div><!– .navigation –>
    <?php endif; // check for comment navigation ?>
     
    <?php else : // or, if we don't have comments:
     
    /* If there are no comments and comments are closed,
    * let's leave a little note, shall we?
    */
    if ( ! comments_open() ) :
    ?>
    <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
    <?php endif; // end ! comments_open() ?>
     
    <?php endif; // end have_comments() ?>
     
    <?php comment_form(); ?>
     
    </div><!– #comments –>
     
     
    CHANGED FILE
     
    <?php
    /**
     * The template for displaying Comments.
     *
     * The area of the page that contains both current comments
     * and the comment form.  The actual display of comments is
     * handled by a callback to twentyten_comment which is
     * located in the functions.php file.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    ?>
     
    <div id="comments">
    <?php if ( post_password_required() ) : ?>
    <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></p>
    </div><!– #comments –>
    <?php
    /* Stop the rest of comments.php from being processed,
    * but don't kill the script entirely — we still have
    * to fully load the template.
    */
    return;
    endif;
    ?>
     
    <?php
    // You can start editing here — including this comment!
    ?>
    <div id="yaapc-comments">
    <?php if ($comments) : ?>
    <h3 id="comments"><?php the_title();?></h3>
    <?php yaapc_pages()?>
    <ol   class="commentlist">
    <?php foreach ($comments as $comment) : ?>
    <ol class="commentlist">
    <?php
    /* Loop through and list the comments. Tell wp_list_comments()
    * to use twentyten_comment() to format the comments.
    * If you want to overload this in a child theme then you can
    * define twentyten_comment() and that will be used instead.
    * See twentyten_comment() in twentyten/functions.php for more.
    */
    wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
    ?>
    <?php endforeach; /* end for each comment */ ?>
    </ol>
    <?php yaapc_pages()?>
    <?php else : // this is displayed if there are no comments so far ?>
    <?php if ('open' == $post->comment_status) : ?>
    <!– If comments are open, but there are no comments. –>
    <?php else : // comments are closed ?>
    <!– If comments are closed. –>
    <p class="nocomments">Comments are closed.</p>
    <?php endif; ?>
    <?php endif; ?>
    </div>
    </div><!– #comments –>

  25. I wondering if i bought a theme and it already had a comment plugin theme set for me and i added your ajex comment plugin would that disable my comments from showing up on my main and article page….please help, go to my page and you will see it for yourself…also please tell me what i can do to fix the problem…
    thanks
    confidentspot

  26. Wow, thanks! I'm using this plugin and I'm very pleased with it's performance. I didn't even have to restyle my comments, which you have to do with most Ajax plugins. However, I want to display my older comments first, and I noticed that this plugin displays the newer comments at the top. Is there anyway I can change this?
    Thanks.

  27. I've found one major issue with the plugin. If you view an attachment (i.e. /?attachment_id=xx), the plugin is forcing WordPress to use the single.php template file instead of using MIME-type or attachment.php files.
    I had to make a small modification at the template_redirect function of the plugin's PHP file, at the beginning, and added an additional conditional check if the requested page was an attachment, then return without redirecting.
                    if ( (!is_single() && !is_page() ) || is_attachment() )
                            return;

    Other than this, the plugin works great!

Leave a Reply

Your email address will not be published.