Как подписать поля для комментариев в Вордпресс?

👍 Научим бесплатно правильно создавать сайты на WordPress. Подробнее →

У меня в теме не подписаны поля для комментариев (Имя, Емайл, Сайт) и пользователи часто путаются из-за этого. Подскажите как подписать эти поля в теме?

Создай свой первый сайт на WordPress

topol
Оцените автора
Добавить комментарий

  1. tiaurus

    Вам нужно найти шаблон, отвечающий за форму комментирования (comments.php или подобный), и в нем найти код, формирующий эту форму. Примерно такой:

    <input class="author-input" type="text" name="author" id="author" value="<?php echo $comment_author; ?>"/>
    <input class="email-input" type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>"/>
    <input class="site-input" type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>"/>
    

    Добавьте к этим строчкам пояснения. Например:

    <label>Имя <input class="author-input" type="text" name="author" id="author" value="<?php echo $comment_author; ?>"/></label>
    <label>E-mail <input class="email-input" type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>"/></label>
    <label>Сайт <input class="site-input" type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>"/></label>
    

    Можете поэкспериментировать с оформлением, главное сами формы для ввода не повредить.

    Ответить
    1. topol автор

      не смог найти даже похожий код… вот содержимое моего comments.php :

      			<div class="commentblock">
      			
      <?php if ( post_password_required() ) : ?>
      				<p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></p>
      			</div><!-- #comments -->
      <?php
      		/* Stop the rest of comments.php from being processed,
      		 * but don't kill the script entirely -- we still have
      		 * to fully load the template.
      		 */
      		return;
      	endif;
      ?>
      
      <?php if ( have_comments() ) : ?>
      			<h4>Отзывы пользователей</h4>
      
      <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
      			<div class="navigation">
      				<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'twentyten' ) ); ?></div>
      				<div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
      			</div> <!-- .navigation -->
      <?php endif; // check for comment navigation ?>
      
      			<ol class="commentlist">
      				<?php
      					/* Loop through and list the comments. Tell wp_list_comments()
      					 * to use twentyten_comment() to format the comments.
      					 * If you want to overload this in a child theme then you can
      					 * define twentyten_comment() and that will be used instead.
      					 * See twentyten_comment() in twentyten/functions.php for more.
      					 */
      					wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
      				?>
      			</ol>
      
      <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
      			<div class="navigation">
      				<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'twentyten' ) ); ?></div>
      				<div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
      			</div><!-- .navigation -->
      <?php endif; // check for comment navigation ?>
      
      <?php else : // or, if we don't have comments:
      
      	/* If there are no comments and comments are closed,
      	 * let's leave a little note, shall we?
      	 */
      	if ( ! comments_open() ) :
      ?>
      	<p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
      <?php endif; // end ! comments_open() ?>
      
      <?php endif; // end have_comments() ?>
      
       <div class="addcomment"> 
      	<?php comment_form(); ?>
      </div>
      
      </div><!-- #comments -->
      
      Ответить
      1. tiaurus

        У вас вид формы комментариев определяется функцией comment_form().

        Ответить
        1. topol автор

          т.е. нужно вставить тот код что вы мне дали в эту функцию?

          Ответить
          1. tiaurus

            Нужно настроить аргументы этой функции. Комментарии для рассказа об этом не подходят, поэтому решил написать отдельный пост, который будет опубликован в ближайшее время.

            Ответить
            1. topol автор

              Спасибо большое, буду с нетерпением ждать статью.

              Ответить
×
WordPress:
прокачай свой сайт!

Скидка на премиум темы и плагины

Успей забрать скидку ⋙