Hide show comments button
-
This really needs to be a feature in the plugin. The wall gets taken up by too many comments. The problem with the following code that was posted is the button always shows if there is no comment made. Needs to only show when a comment is made. The other issue is this breaks replies to the comments Ajax load like it normally does. You have to refresh the page to see any nested comments or replies to replies. Is there any way to add this as a feature or fix the code that was posted?
<?php add_action( 'wp_footer', 'add_comment_hide_show' ); function add_comment_hide_show() { ?> <style> .activity-comments ul li[id^="acomment-"]{display: none;} </style> <script type="text/javascript"> jQuery(function($) { setInterval(function() { $('.activity-meta').each(function() { if( !$(this).find('.show-comments').length ){ var html = '<a href="#" class="button bp-primary-action show-comments">Show/Hide Comments</a>'; $(this).find('.button.acomment-reply').after(html); } }); }, 500); $('body').on('click', '.show-comments', function(e) { e.preventDefault(); var obj = $(this).closest('.activity-content').next('.activity-comments').find('ul li[id^="acomment-"]'); obj.slideToggle(); return false; }); }); </script> <?php }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hide show comments button’ is closed to new replies.