Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show/Hide add new commentbox


  • chris98
    Participant

    @chris98

    Hello,

    I have included the following code, to show and hide the comments, but how I can show and hide the add new Comment textbox too? Actually, I can only show the add new Comment textbox, and if I click on the 1 Comment, the textbox doesnt hide, but the other comments hide.

    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('.comments-count').length ){
                            var html = '<a href="#" class="button bp-primary-action comments-count"></a>';
                            $(this).find('.button.acomment-reply').after(html);
                        }
                    });
    
                }, 500);
    
                $('body').on('click', '.comments-count', function(e) {
                    e.preventDefault();
                    var obj = $(this).closest('.activity-content').next('.activity-comments').find('ul li[id^="acomment-"]');
                    obj.slideToggle();
                    return false;
                });
    
            });
        </script>
  • You must be logged in to reply to this topic.
Skip to toolbar