BuddyBoss Home – Web Support Forums Plugins BuddyBoss Wall Hide and Show Comments on Wall and in Newsfeed

Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Question

    #68938
    @madmax94

    Hallo,

    I have a problem with hidding comments in the activity stream.
    I found a code to hide and show the comments and it works but if i use the code the like count is gone.

    This is the code i use:

    add_action( 'wp_footer', 'add_comment_hide_show' );
    function add_comment_hide_show() {
        ?>
        <style>
        .activity-comments ul{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');
    	obj.slideToggle();
            return false;
          });
    
        });
        </script>
        <?php
    }

    Is there another way to hide and show comments?

    Or how can i show the like count ?

    Sincerely,
    Max

    Answers

    #69110

    Alyssa
    Participant
    @alyssa-buddyboss

    Hwdy Kamil!

    this should do the trick.

    
    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
    }
    

    Cheers!

    #69116
    @madmax94

    Thank you for the answer 😀 .

    The code works but if there are more than 5 comments for e.g. 8 , the last 3 comments are not hidden.

    With the old code all comments are hidden.
    ———–
    And is there an option that all comments are shown because if i use the code (the old code) all commets are hidden but only the first 5 comments be displayed if i click on show. To see all commets i have to click after that on show all (e.g.) 8 comments.

    Thanks 🙂

    #69228
    @vapvarun

    Hi @madmax94,
    These are small customization you can easily use your developer or 3rd party service to do them
    For small customization you can also use https://codeable.io/

    Regard
    Varun Dubey

    #138918
    @bryceevans

    Is there an updated version of either of these codes?

    Neither of them seem to work for me with Boss Theme and Wall plugin.

    #201186
    @jmojonnier

    This works great until someone Likes a post, then Show/Hide freezes for the rest of the page. Any ideas what might be causing that?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this question.