Posted By

kristarella on 02/07/09


Tagged

php jquery thesiswp


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

girliegeek
jealousy
joelhaus
naeemnur
Kurt


Hide/Show Comments on single pages


 / Published in: jQuery
 

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

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.

  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);

Report this snippet  

You need to login to post a comment.