Site logo

Archived topic

Comment

3 replies · Started by John on January 7, 2017

Viewing posts 1–4 of 4

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

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).

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

Please help

Hi there,

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

Thanks!

This archived topic is closed to new replies.