wordpress - having comments inline ajax like in st

2020-05-21 06:50发布

问题:

i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the main page, go in and add comments without first drilling down into a seperate single post page.

Can anyone help here with either a wordpress plugin or php code to do this.

回答1:

I was never able to get AJAXed Wordpress to do what me (and apparently the questioner) want to do.

I use a custom solution that makes use of a plug-in called Inline Ajax Comments. I had a heck of a time finding a download link, but here's one that still works: http://kashou.net/files/inline-ajax-comments.zip

In WordPress' theme editor, I edit index.html. After the following:

<?php the_content(''); ?>

I add (after enabling the plug-in of course):

<?php ajax_comments_link(); ?>
<?php ajax_comments_div(); ?>

I then edited the plugin PHP file itself. I commented out blocks of code as follows:

if ($comment_count == '1') {
    echo('<span id="show-inline-comments-'. $id .'">  ');
    /*  echo('<a href="javascript:;" id="show-inline-comments-link-'. $id .'" onmouseup="ajaxShowComments('. $id .', \''. $throbberURL .'\', \''. $commentpageURL .'\'); return false;">show comment &raquo;</a>'); 
*/
    echo('</span>');
    echo('<span id="hide-inline-comments-'. $id .'" style="display: none;">  ');
    /*  echo('<a href="#comments-'. $id .'" onmouseup="ajaxHideComments('. $id .', \''. $throbberURL .'\', \''. $commentpageURL .'\'); return true;">&laquo; hide comment</a>'); 
*/
    echo('</span>');
} else if ($comment_count > '1') {
    echo('<span id="show-inline-comments-'. $id .'">  ');
    /*  echo('<a href="javascript:;" id="show-inline-comments-link-'. $id .'" onmouseup="ajaxShowComments('. $id .', \''. $throbberURL .'\', \''. $commentpageURL .'\'); return false;">show comments &raquo;</a>'); 
*/
    echo('</span>');
    echo('<span id="hide-inline-comments-'. $id .'" style="display: none;">  ');
    /*  echo('<a href="#comments-'. $id .'" onmouseup="ajaxHideComments('. $id .', \''. $throbberURL .'\', \''. $commentpageURL .'\'); return true;">&laquo; hide comments</a>'); 
*/
    echo('</span>');
}

IIRC, that's all I had to do, but let me know if that doesn't work for you. I'm trying to reverse engineer my own solution since it seems to be exactly what you want to do as well.



回答2:

I think AJAXed Wordpress does what you're looking for, among other things:

AJAXed Wordpress

AJAXed Wordpress (AWP) harnesses the power of both AJAX and Wordpress to improve the user experience, the administration capabilities and the design potential of any Wordpress based blog. It works on all WordPress versions from 2.1 - 2.6.

Some of AWP’s features include loading posts inline, inline comments, threaded comments, AJAX comment submission, AJAX Navigation, live comment preview and much more. AWP is endlessly customizable and extensible. Even though AWP provides many features, you are never forced to use features that you don’t want. All aspects of the plugin are easily customized through a single Administration panel.

Demo is available here http://wordpress.mu/ and you can see the inline comments in action. Looks like what you were asking for.



回答3:

You could repurpose code from P2 theme. It's a rather well written theme so this should largely work without any problems. Copy all the code from their functions.php to the bottom of your theme's functions.php. Copy their inc directory and entry.php to your theme directory.

Replace in your index.php

  <?php if (have_posts()) : ?> 

    <?php while (have_posts()) : the_post(); ?> 
    <?php /* your themes code must be here */ ?>

  <?php endwhile; ?> 

with

  <?php if (have_posts()) : ?> 

    <?php while (have_posts()) : the_post(); ?> 
    <?php  require dirname(__FILE__) . '/entry.php'; ?> 

  <?php endwhile; ?> 

and then modify the css and other stuff in entry.php to taste.



回答4:

I recommend this http://wordpress.org/extend/plugins/ajax-comment-posting/ . I hope it helps.



回答5:

You might want to try Ajax Comment Posting. It works for me.

There are many comment-related plugins in Wordpress plugin directory. However, if you'd like to find just a simple comment-posting Ajax plugin, you won't find any. That's why I developed a simple and small (5kB) yet functional Ajax Comment Posting (ACP) plugin. Not only will it post your comment without refreshing the page, but it will also make sure that you've filled all the form fields correctly.



回答6:

You could use a 1. AJAX comments plugins (search for "Ajax comments" on wordpress) 2. Write your own custom code. 3. Use disqus.

Regardless of the option you choose from the above, you still need to expose comments on the main page. This can be done (based on the option you choose) by changing the index.php of your template, to display comments after displaying the text of every post. however, this will increase page load times, and also affect the design of your main page (plus linking to a specific page will not have much value anymore).



回答7:

There are a lot of plugins doing that. Ajax Comment Posting is pretty simple to install and use. As they say:

  1. Upload the plugin directory ajax-comment-posting to the wp-content/plugins directory.
  2. Activate the plugin through the 'Plugins' menu in WordPress.
  3. That's it!

http://wordpress.org/extend/plugins/ajax-comment-posting/