Loading post comments after clicking a button

Discussion in 'WordPress' started by Divvy, Jan 20, 2023.

  1. #1
    Hello, can someone help me hide the comments form and show it when someone clicks a button?
    This what's I'm trying to hide: https://prnt.sc/Q4RXOb_n6XYT

    I've found a snippet to show the comments on click, maybe we can change the code to work with the comments form as well.

    function your_hidden_comments(){ ?>
    <script type="text/javascript" defer="defer">
    var comment_div = jQuery('#comments');
    if(comment_div[0]){
    jQuery('<button id="show_comments">Show Comments</button>').insertBefore(comment_div);
    comment_div.hide();
    jQuery('#show_comments').on('click',function(){ comment_div.fadeIn('slow'); jQuery('#show_comments').fadeOut('slow'); });
    }
    </script>
    <?php }
    
    add_action('wp_footer', 'your_hidden_comments');
    PHP:
    This is a post of mine:
    https://bestlistofporn.com/playboyplus
    (NSFW content)

    Thank you in advance :)
     
    Divvy, Jan 20, 2023 IP
  2. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    Fixed, thank you anyway guys!
     
    Divvy, Jan 27, 2023 IP