Support » Fixing WordPress » Editing Comment Form Labels

  • Resolved prayersnapples


    I tried changing the text next to one of my comment form entry boxes (Instead of ‘Mail (will not be published)’ I wanted to insert different text, but it didn’t work. Here’s where I went in and edited (I replaced the ‘Mail….’ text with my own – but when I tested it, I got an error message on the site where the comment form usually shows):

    <p><input type="text" class="rounded" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" />
    <label for="email"><small><?php _e('Mail (will not be published)');?> <?php if ($req) _e('(required)'); ?></small></label></p>

    Is there something else I should be changing?

    My site is:

Viewing 6 replies - 1 through 6 (of 6 total)
  • Also, is there a way to delete the email box field completely? I think it’s deterring a lot of people from leaving comments because they’re in a rush/worried they’re going to end up on some sort of mailing list, etc.

    I found this site, which offers the same type of advice I’ve found from Googling:

    WordPress 3.0 Theme Tip: The Comment Form

    It all seems really complicated (I’m not very tech-savy) and I’m just hoping there’s an easier way – all I want to do is change a couple words: ‘Mail (will not be published)’.

    I’ve found earlier threads on here, but they all seem similar to the information in the link above. Any simpler solutions?

    Nope. That’s about as simple as it gets.

    I don’t understand, because I did it before without doing all of that? The heading of the comment form used to say “Leave a comment” and I just deleted that text and changed it to “What is your opinion?” and it worked. It was when I first started my site several months ago, and I was reading a ton of support forum articles, so I honestly don’t remember exactly how I did it or where I had to go – but I know 100% it wasn’t anything like what that link said. It was basically just deleting and inserting what text I wanted. But now when I locate that “What is your opinion?” text in my commments.php and try to change it, the changes won’t show! I’m really confused by this. Here’s my comments.php:

    // Do not delete these lines
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die ('Thanks to not load this page directly.');
    if ( post_password_required() ) : ?>
    <p><?php _e('Enter your password to view comments.'); ?></p>
    <?php return; endif; ?>
    <aside id="comments">
    <?php if ( have_comments() ) : ?>
    	<h2><?php comments_number(__('No comments'), __('1 Comment'), __('% Comments')); ?>
    <?php if ( comments_open() ) : ?>
    	<a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
    <?php endif; ?></h2>
    	<div class="pages">
    		<div class="left"><?php previous_comments_link() ?></div>
    		<div class="right"><?php next_comments_link() ?></div>
    	<ol class="commentlist">
    	<?php foreach ($comments as $comment) : ?>
            <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
            <div class="quote">
                        echo get_avatar(get_comment_author_email(), '35');
    		<?php comment_text() ?></div>
            <?php if ($comment->comment_approved == '0') : ?>
            <em>Your comment is awaiting moderation.</em>
            <?php endif; ?>
            <cite><?php comment_author_link() ?> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?></a></cite>
        <?php endforeach; /* end for each comment */ ?>
    	<div class="pages">
    		<div class="left"><?php previous_comments_link() ?></div>
    		<div class="right"><?php next_comments_link() ?></div>
     <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ( comments_open() ) : ?>
    		<!-- If comments are open, but there are no comments. -->
            <p><?php _e('Start a conversation!'); ?></p>
    	 <?php else : // comments are closed ?>
    		<!-- If comments are closed. -->
    		<p class="nocomments">Comments are closed.</p>
    	<?php endif; ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
    <div id="respons">
    <h2><?php comment_form_title( 'What is your opinion?' ); ?></h2>
    <div class="cancel-comment-reply">
    	<small><?php cancel_comment_reply_link(); ?></small>
    <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    <p>You must be  <a href="<?php echo wp_login_url( get_permalink() ); ?>">connected</a> to post a comment.</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>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out.">Log out &raquo;</a></p>
    <?php else : ?>
    <p><input type="text" class="rounded" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" />
    <label for="author"><small><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>
    <p><input type="text" class="rounded" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" />
    <label for="email"><small><?php _e('Mail (will not be published)');?> <?php if ($req) _e('(required)'); ?></small></label></p>
    <p><input type="text" class="rounded" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
    <label for="url"><small><?php _e('Website'); ?></small></label></p>
    <?php endif; ?>
    <!--<p><small><strong>XHTML:</strong> <?php printf(__('You can use these tags: %s'), allowed_tags()); ?></small></p>-->
    <p><textarea name="comment" class="rounded" id="comment" cols="60" rows="10" tabindex="4"></textarea></p>
    <p><input name="submit" class="rounded" type="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment'); ?>" />
    <?php comment_id_fields(); ?>
    <?php do_action('comment_form', $post->ID); ?>
    <?php endif; // If registration required and not logged in ?>
    <?php endif; // if you delete this the sky will fall on your head ?>

    Here’s the article that describes how I initially changed it:

    But now it doesn’t work?

    I figured it out! All you have to do (at least on my theme) is going into comments.php and switch out the text you want (as described in the link above). And then (…and this is why it wasn’t working for me) you have to delete caches if you’re using WP Super Cache (which I wasn’t using when I first started my blog – which is why it worked then but didn’t seem to work now). Once you delete those, your changes will show! 🙂 I changed the text for the comment form header and for the text next to the email field.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Editing Comment Form Labels’ is closed to new replies.