WordPress.org

Forums

[resolved] 1st AJAX Comments appear below form (5 posts)

  1. Sphagnum
    Member
    Posted 9 years ago #

    I've installed AJAX commenting on a new theme I'm tweaking for my blog:
    http://peatbog.net/?wptheme=Peat Bog 2.0

    I ripped the AJAX commenting code from the K2 theme:
    http://binarybonsai.com/k2/

    Here is the problem. When I post a comment, if it is the first comment, it says "Loading comment" where I would expect the first comment to appear, but then that disappears and the comment appears way down below the comment form. If there is already a comment posted, then t he code works fine. It's only when I'm puting up the first comment. Problem is, I'm not very up on javascript. I THINK the problem lies in one of these two bits of code in the comments-ajax.php file that I got from the K2 theme:


    $post->comment_status = $wpdb->get_var("SELECT comment_status FROM {$wpdb->posts} WHERE ID = {$comment_post_ID}");

    ob_start();
    $comments = array($comment);
    include(TEMPLATEPATH . '/comments.php');
    $commentout = ob_get_clean();
    preg_match('#<li(.*?)>(.*)#ims', $commentout, $matches);
    echo "<li style=\"display:none\"".$matches[1].">".$matches[2]."";

    ?>

    can someone help me decode this? If I'm correct in these two lines beign the problem, where is it sending the comment to appear? Is it sending it to a div id perhaps that I need to change?

    If this is way off, I can provide other code or copy the entire comments file for further inspection.

    I really appreciate the help in advance!

  2. Sphagnum
    Member
    Posted 9 years ago #

    The link to my blog's new, green theme is off.

    It is here:

    http://peatbog.net/?wptheme=Peat Bog 2.0

  3. Sphagnum
    Member
    Posted 9 years ago #

    Woah, when I did that second comment, it appears AJAX commenting is part of this forum now. It's a better look than the code I'm using gives. Anywhere the code used on this forum is available for copy?

  4. Sphagnum
    Member
    Posted 9 years ago #

    Just to follow up once agai, I did get AJAXed commenting installed on my site. Feel free to check it out: http://peatbog.net

  5. war59312
    Member
    Posted 9 years ago #

    Very nice! :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags