Avatar w komentarzu
-
Witam,
Problem polega na tym, że kiedy ktoś doda komentarz pod wpisem w miejsce avatara pojawia się avatar autora wpisu, a nie komentującego.
Plik comments.php:
<div class="col-md-8"> <h3>Komentarze:</h3> <?php cancel_comment_reply_link(); ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <div class="form-group"> <input type="text" name="author" id="author" value="<?php $current_user = wp_get_current_user(); echo $current_user->user_firstname ?> <?php echo $current_user->user_lastname ?>" class="form-control" <?php if ($req) echo "aria-required='true'"; ?> > <label for="author">Imię <?php if ( $req ) echo "( wymagane )"; ?></label> </div> <div class="form-group"> <input type="email" name="email" id="email" value="<?php $current_user = wp_get_current_user(); echo $current_user->user_email ?>" class="form-control" <?php if ($req) echo "aria-required='true'"; ?>> <label for="email">Email ( <?php if ( $req ) echo "wymagane"; ?> )</label> </div> <div class="form-group"> <textarea name="comment" id="message"></textarea> <label for="comment">Twój komentarz (min. 15 znaków)</label> </div> <button class="submit"> <?php do_action( 'comment_form', $post->ID ); comment_id_fields(); ?>Wyślij komentarz</button> </form> </div> <!-- Odwołanie się do funkcji wyglądu komentarzy z pliku functions.php --> <?php wp_list_comments( array( 'type' => 'comment', 'callback' => 'comments_feed_template_callback' ) ); ?>
Plik function.php
function comments_feed_template_callback($comment, $args, $depth) { $GLOBAL['comment'] = $comment; ?> <div class="comment-display"> <a href="<?php get_comment_author_url(); ?>" class="pull-left img-circle"> <? echo get_avatar( get_the_author_meta('user_email'), $size = '55'); ?> </a> <div class="comment-content"> <h5 class="media-heading"> <a href="<?php get_comment_author_url(); ?>"><?php echo get_comment_author(); ?></a> <small><?php comment_date(); ?> o <?php comment_time(); ?></small> </h5> <?php comment_text(); ?> <?php comment_reply_link(array_merge($args, array( 'reply_text' => __('<strong>Odpowiedz </strong><i class="icon-share-alt"></i>'), 'depth' => $depth, 'max_depth' => $args['max_depth'] ))); ?> </div> </div> <hr> <?php }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- Temat ‘Avatar w komentarzu’ jest zamknięty na nowe odpowiedzi.