I make on the page the output of my commenting template. The output of comments made, the form of commenting with the fields made.
How to make the fields in the comments template and make it possible to upload photos and post them as avatars?
<?php /* Template Name: Страница "Отзывы" Template Post Type: page */ $fields = (object)get_fields(); ?> <?php get_header(); ?> <?php get_sidebar(); ?> <section> <div class="title_wrap text_center"> <div class="shadow_title "><?= $fields->title ?></div> <h1 class="title "><?= $fields->title ?></h1> </div> <div class="all_testimonials"> <?php if($fields->testimonials): ?> <?php foreach($fields->testimonials AS $t): ?> <div class="one_wrap"> <div class="single_testimonial clearfix"> <div class="foto"> <img src="<?= WP_img_resize($t['photo'], 127, 127, true) ?>" alt=""> </div> <div class="testimonial_content"> <div class="fst clearfix"> <div class="name"><?= $t['name'] ?></div> <div class="date"><?= $t['date_comment'] ?></div> </div> <?php if($t['order']): ?> <div class="zakaz"><?= $t['order'] ?></div> <?php endif; ?> <div class="text"> <?= $t['comment'] ?> </div> </div> </div> <div class="asnwer box-shadow"> <div class="clearfix"> <div class="title"> Ответ представителя: </div> <div class="date"> <?= $t['date_answer'] ?> </div> </div> <?= $t['answer'] ?> </div> </div> <?php endforeach; ?> <?php endif; ?> <?php $comments = get_comments() ? get_comments() : ''; if($comments): ?> <?php foreach($comments AS $comment): ?> <?php if($comment->comment_parent == 0): ?> <div class="one_wrap"> <div class="single_testimonial clearfix"> <div class="foto"> <img src="<?= WP_img_resize($t['photo'], 127, 127, true) ?>" alt=""> </div> <div class="testimonial_content"> <div class="fst clearfix"> <div class="name"><?= $comment->comment_author ?></div> <div class="date"><?= dateFormat($comment->comment_date) ?></div> </div> <div class="text"> <?= $comment->comment_content ?> </div> </div> </div> <?php foreach($comments AS $_c): ?> <?php if($_c->comment_parent == $comment->comment_ID): ?> <div class="asnwer box-shadow"> <div class="clearfix"> <div class="title"> Ответ представителя: </div> <div class="date"> <?= dateFormat($_c->comment_date) ?> </div> </div> <?= $_c->comment_content ?> </div> <?php endif; ?> <?php endforeach; ?> </div> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> </div> <?php if(comments_open() || get_comments_number()){ $fields = array( 'author' => '<label class="comment-form-author">Ваше имя'. '<input id="author" name="author" type="text" value="" size="30" placeholder="Ваше имя" required/></label> ', 'email' => '<label class="comment-form-email">Ваша почта'. '<input id="email" name="email" type="email" value="" size="30" placeholder="Ваша почта" required/></label>', 'order' => '<label class="comment-form-text">Ваш заказ'. '<input id="text" name="text" type="number" value="" size="30" placeholder="Ваш заказ" required/></label>', 'photo' => '<label class="comment-form-file">Ваше фото'. '<input id="file" name="file" type="file" value="" size="30" placeholder="Ваше фото" required accept="image/*" onchange="loadFile(event)"/></label> <img id="output"/>', ); $c_args = array( 'fields' => $fields, 'comment_field' => '<label class="comment-form-comment">Ваш отзыв<textarea id="comment" name="comment" aria-required="true" placeholder="Ваш отзыв" required></textarea></label>', 'title_reply'=>'', 'logged_in_as'=>'', 'comment_notes_before'=>'' ); function sort_comment_fields( $fields ){ $new_fields = array(); $my_comment = array('author','email','order','file','comment'); // порядок полей foreach( $my_comment as $key ){ $new_fields[ $key ] = $fields[ $key ]; unset( $fields[ $key ] ); } if( $fields ) foreach( $fields as $key => $val ) $new_fields[ $key ] = $val; return $new_fields; } add_filter('comment_form_fields', 'sort_comment_fields' ); /*echo '<div id="leave_testimonial" class="popup_form"> <div class="title_line"> Оставить отзыв о квесте <span>Форт Боярд</span> </div> <div class="inputs_wrap">';*/ comment_form($c_args); /*echo '</div></div>';*/ } ?> <hr> <div class="btn_holder"> <a href="javascript:void(0);">Оставить отзыв</a> </div> <script> jQuery(".comment-respond").hide(); jQuery(document).ready(function() { jQuery(".btn_holder").click(function(){ jQuery(".comment-respond").toggle('slow'); }); }); </script> <script> var loadFile = function(event) { var output = document.getElementById('output'); output.src = URL.createObjectURL(event.target.files[0]); }; </script> <!--<div class="pagination"> <ul> <li class="current"><a href="#"><1></a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">Показать все</a></li> </ul> </div>--> </section> <div class="comment"> <?php if( get_field('upload_image', $comment) ): ?> <img src="<?php the_field('image', $comment); ?>" /> <?php endif; ?> </div> <?php get_footer(); ?>
<?=Hands need to tear off. On the very throat - SeVlad