change comment heading if no comments added

Curious if there's a way to display two different headings based on whether comments have been posted or not.

Currently I have "Join the conversation" as the heading on the comments section, but it would be MUCH cooler to say "START the conversation" if no comments have been added.

Any theme devs know how to do this?

    peter_harris

    Ooops, can't attach the file so here's the code:

    <?php function reverie_comments($comment, $args, $depth) {
    	$GLOBALS['comment'] = $comment; ?>
    	<li <?php comment_class(); ?>>
    		<article id="comment-<?php comment_ID(); ?>">
    			<header class="comment-author">
    				<?php echo get_avatar($comment,$size='48'); ?>
    				<div class="author-meta">
    					<?php printf(__('<cite class="fn">%s</cite>', 'reverie'), get_comment_author_link()) ?>
    					<time datetime="<?php echo comment_date('c') ?>"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s', 'reverie'), get_comment_date(),  get_comment_time()) ?></a></time>
    					<?php edit_comment_link(__('(Edit)', 'reverie'), '', '') ?>
    				</div>
    			</header>
    
    			<?php if ($comment->comment_approved == '0') : ?>
           			<div class="notice">
    					<p class="bottom"><?php _e('Your comment is awaiting moderation.', 'reverie') ?></p>
              		</div>
    			<?php endif; ?>
    
    			<section class="comment">
    				<?php comment_text() ?>
    				<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    			</section>
    
    		</article>
    <?php } ?>
    
    <?php
    // Do not delete these lines
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die (__('Please do not load this page directly. Thanks!', 'reverie'));
    
    	if ( post_password_required() ) { ?>
    	<section id="comments">
    		<div class="notice">
    			<p class="bottom"><?php _e('This post is password protected. Enter the password to view comments.', 'reverie'); ?></p>
    		</div>
    	</section>
    	<?php
    		return;
    	}
    ?>
    <?php // You can start editing here. Customize the respond form below ?>
    <?php if ( have_comments() ) : ?>
    	<section id="comments">
    		<h3><?php comments_number(__('No Responses to', 'reverie'), __('One Response to', 'reverie'), __('% Responses to', 'reverie') ); ?> “<?php the_title(); ?>”</h3>
    		<ol class="commentlist">
    		<?php wp_list_comments('type=comment&callback=reverie_comments'); ?>
    
    		</ol>
    		<footer>
    			<nav id="comments-nav">
    				<div class="comments-previous"><?php previous_comments_link( __( '&larr; Older comments', 'reverie' ) ); ?></div>
    				<div class="comments-next"><?php next_comments_link( __( 'Newer comments &rarr;', 'reverie' ) ); ?></div>
    			</nav>
    		</footer>
    	</section>
    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ( comments_open() ) : ?>
    	<?php else : // comments are closed ?>
    
    	<?php endif; ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
    <section id="respond">
    	<h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>
    	<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
    	<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    	<p><?php printf( __('You must be <a href="%s">logged in</a> to post a comment.', 'reverie'), wp_login_url( get_permalink() ) ); ?></p>
    	<?php else : ?>
    	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    		<?php if ( is_user_logged_in() ) : ?>
    		<p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'reverie'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'reverie'); ?>"><?php _e('Log out &raquo;', 'reverie'); ?></a></p>
    		<?php else : ?>
    		<p>
    			<label for="author"><?php _e('Name', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<p>
    			<label for="email"><?php _e('Email (will not be published)', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<?php endif; ?>
    		<p>
    			<label for="comment"><?php _e('Comment', 'reverie'); ?></label>
    			<textarea name="comment" id="comment" tabindex="4"></textarea>
    		</p>
    		<p><input name="submit" class="small radius button" type="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment', 'reverie'); ?>"></p>
    		<?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    	</form>
    	<?php endif; // If registration required and not logged in ?>
    </section>
    <?php endif; // if you delete this the sky will fall on your head ?>
    Vaughan

    Hi Peter,

    There's 2 ways you can do this, either edit the file directly (Though this would be best done by creating a child theme first so that your changes are not overwritten on updating the theme)

    To edit the file directly;

    Find the following line;

    <h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>

    then we change the text for Join the conversation to Start a conversation

    <h3><?php comment_form_title( __('Start the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>

    The 2nd way, would require editing the language translation file of the theme using a tool such as poedit from http://poedit.net

    Then upload the new .mo translation file (produced by poedit) to /wp-content/languages/themes/

    This wouldn't require a child theme.

    I also just thought of a third way too, you can use the ultimate branding plugin and enable the network wide text change module, this would allow you to edit the text via the dashboard.

    https://premium.wpmudev.org/project/ultimate-branding/#usage

    Hope this helps

    Ash

    Hello @peter_harris

    I hope you are well today.

    Please try the following code:

    <?php function reverie_comments($comment, $args, $depth) {
    	$GLOBALS['comment'] = $comment; ?>
    	<li <?php comment_class(); ?>>
    		<article id="comment-<?php comment_ID(); ?>">
    			<header class="comment-author">
    				<?php echo get_avatar($comment,$size='48'); ?>
    				<div class="author-meta">
    					<?php printf(__('<cite class="fn">%s</cite>', 'reverie'), get_comment_author_link()) ?>
    					<time datetime="<?php echo comment_date('c') ?>"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s', 'reverie'), get_comment_date(),  get_comment_time()) ?></a></time>
    					<?php edit_comment_link(__('(Edit)', 'reverie'), '', '') ?>
    				</div>
    			</header>
    
    			<?php if ($comment->comment_approved == '0') : ?>
           			<div class="notice">
    					<p class="bottom"><?php _e('Your comment is awaiting moderation.', 'reverie') ?></p>
              		</div>
    			<?php endif; ?>
    
    			<section class="comment">
    				<?php comment_text() ?>
    				<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    			</section>
    
    		</article>
    <?php } ?>
    
    <?php
    // Do not delete these lines
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die (__('Please do not load this page directly. Thanks!', 'reverie'));
    
    	if ( post_password_required() ) { ?>
    	<section id="comments">
    		<div class="notice">
    			<p class="bottom"><?php _e('This post is password protected. Enter the password to view comments.', 'reverie'); ?></p>
    		</div>
    	</section>
    	<?php
    		return;
    	}
    ?>
    <?php // You can start editing here. Customize the respond form below ?>
    <?php if ( have_comments() ) : ?>
    	<section id="comments">
    		<h3><?php comments_number(__('No Responses to', 'reverie'), __('One Response to', 'reverie'), __('% Responses to', 'reverie') ); ?> “<?php the_title(); ?>”</h3>
    		<ol class="commentlist">
    		<?php wp_list_comments('type=comment&callback=reverie_comments'); ?>
    
    		</ol>
    		<footer>
    			<nav id="comments-nav">
    				<div class="comments-previous"><?php previous_comments_link( __( '&larr; Older comments', 'reverie' ) ); ?></div>
    				<div class="comments-next"><?php next_comments_link( __( 'Newer comments &rarr;', 'reverie' ) ); ?></div>
    			</nav>
    		</footer>
    	</section>
    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ( comments_open() ) : ?>
    	<h3><?php comment_form_title( __('Start the Conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>
    	<?php else : // comments are closed ?>
    
    	<?php endif; ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
    <section id="respond">
    	<h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>
    	<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
    	<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    	<p><?php printf( __('You must be <a href="%s">logged in</a> to post a comment.', 'reverie'), wp_login_url( get_permalink() ) ); ?></p>
    	<?php else : ?>
    	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    		<?php if ( is_user_logged_in() ) : ?>
    		<p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'reverie'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'reverie'); ?>"><?php _e('Log out &raquo;', 'reverie'); ?></a></p>
    		<?php else : ?>
    		<p>
    			<label for="author"><?php _e('Name', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<p>
    			<label for="email"><?php _e('Email (will not be published)', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<?php endif; ?>
    		<p>
    			<label for="comment"><?php _e('Comment', 'reverie'); ?></label>
    			<textarea name="comment" id="comment" tabindex="4"></textarea>
    		</p>
    		<p><input name="submit" class="small radius button" type="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment', 'reverie'); ?>"></p>
    		<?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    	</form>
    	<?php endif; // If registration required and not logged in ?>
    </section>
    <?php endif; // if you delete this the sky will fall on your head ?>

    Hope it helps Please feel free to ask more question if you have any.

    Cheers
    Ash

    Ash

    Hello @peter_harris

    Please try this

    <?php function reverie_comments($comment, $args, $depth) {
    	$GLOBALS['comment'] = $comment; ?>
    	<li <?php comment_class(); ?>>
    		<article id="comment-<?php comment_ID(); ?>">
    			<header class="comment-author">
    				<?php echo get_avatar($comment,$size='48'); ?>
    				<div class="author-meta">
    					<?php printf(__('<cite class="fn">%s</cite>', 'reverie'), get_comment_author_link()) ?>
    					<time datetime="<?php echo comment_date('c') ?>"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s', 'reverie'), get_comment_date(),  get_comment_time()) ?></a></time>
    					<?php edit_comment_link(__('(Edit)', 'reverie'), '', '') ?>
    				</div>
    			</header>
    
    			<?php if ($comment->comment_approved == '0') : ?>
           			<div class="notice">
    					<p class="bottom"><?php _e('Your comment is awaiting moderation.', 'reverie') ?></p>
              		</div>
    			<?php endif; ?>
    
    			<section class="comment">
    				<?php comment_text() ?>
    				<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    			</section>
    
    		</article>
    <?php } ?>
    
    <?php
    // Do not delete these lines
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die (__('Please do not load this page directly. Thanks!', 'reverie'));
    
    	if ( post_password_required() ) { ?>
    	<section id="comments">
    		<div class="notice">
    			<p class="bottom"><?php _e('This post is password protected. Enter the password to view comments.', 'reverie'); ?></p>
    		</div>
    	</section>
    	<?php
    		return;
    	}
    ?>
    <?php // You can start editing here. Customize the respond form below ?>
    <?php if ( have_comments() ) : ?>
    	<section id="comments">
    		<h3><?php comments_number(__('No Responses to', 'reverie'), __('One Response to', 'reverie'), __('% Responses to', 'reverie') ); ?> “<?php the_title(); ?>”</h3>
    		<ol class="commentlist">
    		<?php wp_list_comments('type=comment&callback=reverie_comments'); ?>
    
    		</ol>
    		<footer>
    			<nav id="comments-nav">
    				<div class="comments-previous"><?php previous_comments_link( __( '&larr; Older comments', 'reverie' ) ); ?></div>
    				<div class="comments-next"><?php next_comments_link( __( 'Newer comments &rarr;', 'reverie' ) ); ?></div>
    			</nav>
    		</footer>
    	</section>
    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ( comments_open() ) : //If comments are open ?>
    
    	<?php else : // comments are closed ?>
    
    	<?php endif; ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
    <section id="respond">
    	<h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>
    	<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
    	<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    	<p><?php printf( __('You must be <a href="%s">logged in</a> to post a comment.', 'reverie'), wp_login_url( get_permalink() ) ); ?></p>
    	<?php else : ?>
    	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    		<?php if ( is_user_logged_in() ) : ?>
    		<p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'reverie'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'reverie'); ?>"><?php _e('Log out &raquo;', 'reverie'); ?></a></p>
    		<?php else : ?>
    		<p>
    			<label for="author"><?php _e('Name', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<p>
    			<label for="email"><?php _e('Email (will not be published)', 'reverie'); if ($req) _e(' (required)', 'reverie'); ?></label>
    			<input type="text" class="five" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
    		</p>
    		<?php endif; ?>
    		<p>
    			<label for="comment"><?php _e('Comment', 'reverie'); ?></label>
    			<textarea name="comment" id="comment" tabindex="4"></textarea>
    		</p>
    		<p><input name="submit" class="small radius button" type="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment', 'reverie'); ?>"></p>
    		<?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    	</form>
    	<?php endif; // If registration required and not logged in ?>
    </section>
    <?php endif; // if you delete this the sky will fall on your head ?>

    Cheers
    Ash

    Timothy Bowers

    Hey there,

    Try replacing the line:

    <h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Leave a Reply to %s', 'reverie') ); ?></h3>

    With:

    <?php if (have_comments()) { ?>
    		<h3><?php comment_form_title( __('Join the conversation', 'reverie'), __('Let %s know what you think.', 'reverie') ); ?></h3>
    <?php } else { ?>
    		<h3><?php comment_form_title( __('Start the Conversation', 'reverie')); ?></h3>
    <?php } ?>

    I'm guessing you created a custom comments.php file in a child theme for Reverie theme, just in case you didn't I wanted to mention that it would be advisable to.

    https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    I tested, it worked for me. Let me know how it goes for you.

    Hope this helps get what you need.

    Have a great day!