Return to Snippet

Revision: 11492
at February 7, 2009 00:17 by kristarella


Initial Code
function custom_jquery() { ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("div#comments").hide();
        $("p#show_comments > a").click(function(){
            $("div#comments").show();
        });
    });
</script>
<?php }
add_action('wp_head', 'custom_jquery');

function show_comments() {
if (is_single()) {
    echo '<p id="show_comments"><a href="#comments">Show Comments</a></p>';
}
}
add_action('thesis_hook_after_post', 'show_comments', 99);

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

Initial Description
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.

Initial Title
Hide/Show Comments on single pages

Initial Tags
php, jquery

Initial Language
jQuery