Hide/Show Comments on single pages


/ Published in: jQuery
Save to your folder(s)

This is a bit of jQuery within a PHP function that you can dump into your Thesis custom_functions.php file to hide comments upon page load and add a link to show them.


Copy this code and paste it in your HTML
  1. function custom_jquery() { ?>
  2. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
  3. <script type="text/javascript">
  4. $(function(){
  5. $("div#comments").hide();
  6. $("p#show_comments > a").click(function(){
  7. $("div#comments").show();
  8. });
  9. });
  10. </script>
  11. <?php }
  12. add_action('wp_head', 'custom_jquery');
  13.  
  14. function show_comments() {
  15. if (is_single()) {
  16. echo '<p id="show_comments"><a href="#comments">Show Comments</a></p>';
  17. }
  18. }
  19. add_action('thesis_hook_after_post', 'show_comments', 99);

URL: http://diythemes.com/forums/thesis-customization/3475-show-hide-comments.html#post17870

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.