[Support request] Comment

Home Forums Support Comment

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #261552
    John

    Hi Tom.

    I would like the have something like this under a post, is this possible and how do i do that?

    Kind regards
    John

    if comments=0 then
    print “please give a comment”;
    else if comments>0 then
    print “x comments – please give a comment”;
    endif

    #261638
    Tom
    Lead Developer
    Lead Developer

    To make it say “Please give a comment”, you can use this filter: https://docs.generatepress.com/article/generate_leave_comment/

    Then, add this CSS:

    .comments-title {
        display: none;
    }
    
    .comments-title.custom-comments-title {
        display: block;
    }

    Then, add this PHP:

    add_action( 'generate_below_comments_title','tu_custom_comments_title' );
    function tu_custom_comments_title() { ?>
        <h3 class="comments-title custom-comments-title">
            <?php					
    		$comments_number = get_comments_number();
    		if ( 1 === $comments_number ) {
    			echo esc_html_x( '1 comment - please give a comment', 'comments title', 'generatepress' ),
    		} else {
    			printf( // WPCS: XSS OK.
    				/* translators: 1: number of comments */
    				esc_html( _nx(
    					'%1$s comment - please give a comment',
    					'%1$s comments - please give a comment',
    					$comments_number,
    					'comments title',
    					'generatepress'
    				) ),
    				number_format_i18n( $comments_number )
    			);
    		}
    	?>
        </h3>
    <?php }

    That should do it (untested).

    #538071
    Huy

    Hi
    I want to add entry meta and comment area in ” no sidebar” layout

    Please help

    #538187
    Leo
    Staff
    Customer Support

    Hi there,

    Can you open a new topic for your question and explain a bit more?

    Thanks!

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