Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to load site comments on-demand instead of having them always display at the bottom of the post? Like by clicking on Load Comments....

You can check labnol.org. They are using Disqus comment system which loads by clicking.

How could I achieve that?

share|improve this question
1  
If you are using WordPress then you could use this plugin: Disqus Conditional Load –  Joel Says Jun 13 at 5:35
add comment

2 Answers 2

up vote 0 down vote accepted

You could try an easy jQuery approach of hiding the comments div and inserting a button to make it appear.

Instructions:

In your functions.php file of your theme, place this line of code to ensure that jQuery has been included to run the code:

wp_enqueue_script('jquery');

Then you could add this function to place the javascript code into the footer of each of your webpages:

function your_hidden_comments(){ ?>
<script type="text/javascript" defer="defer">
var comment_div = jQuery('#comments');
if(comment_div[0]){

    jQuery('<button id="show_comments">Show Comments</button>').insertBefore(comment_div);

    comment_div.hide();

    jQuery('#show_comments').on('click',function(){ comment_div.fadeIn('slow'); jQuery('#show_comments').fadeOut('slow'); });
}
</script>
<?php } 

add_action('wp_footer', 'your_hidden_comments');

I hope that helps; comment back if there is any trouble with this.

share|improve this answer
    
sir i'm not getting it where and how to add it its a bit confusing would you kindly clarify me a bit should i use it like this ..... <?php wp_enqueue_script("jquery"); ?> <?php wp_footer(); ?> <script type="text/javascript"> var comment_div = jQuery('#comments'); jQuery('<button id="show_comments" value="show_comments"></button>').prependTo(comment_div); comment_div.hide(); jQuery('#show_comments').on('click',function(){ comment_div.fadeIn('slow'); jQuery('#show_comments').fadeOut('slow'); }); }); </script> –  Arafin Shaon Sep 12 '12 at 3:05
    
Just made an edit; I hope that helps. –  Douglas.Sesar Sep 12 '12 at 4:02
    
Tnx for your effort. I tried it on wordpress 2011 theme but unfortunately not working. Even after installed disqus commenting system….. –  Arafin Shaon Sep 12 '12 at 13:05
    
If you are using chrome, right-click and select 'inspect element'. Then select the 'console' tab and let me know what the javascript error says (if there is one) –  Douglas.Sesar Sep 12 '12 at 15:24
    
After adding the code my comments being hidden but load comments button is not appearing to make them loading and console is showing error.... "Failed to load resource" –  Arafin Shaon Sep 12 '12 at 18:12
show 10 more comments

This plugin doesn't do it "on click", but it does modify the comment system to load comments after the page has loaded, giving you faster initial page load times.

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

Works well, I use it on many sites.

share|improve this answer
    
this is not what i'm looking i want my comments to be hidden –  Arafin Shaon Sep 14 '12 at 5:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.