{"id":64613,"date":"2017-05-23T09:59:00","date_gmt":"2017-05-23T07:59:00","guid":{"rendered":"https:\/\/pl.wordpress.org\/support\/topic\/avatar-w-komentarzu\/"},"modified":"2017-05-23T09:59:00","modified_gmt":"2017-05-23T07:59:00","slug":"avatar-w-komentarzu","status":"publish","type":"topic","link":"https:\/\/pl.wordpress.org\/support\/topic\/avatar-w-komentarzu\/","title":{"rendered":"Avatar w komentarzu"},"content":{"rendered":"<p>Witam,<\/p>\n<p>Problem polega na tym, \u017ce kiedy kto\u015b doda komentarz pod wpisem w miejsce avatara pojawia si\u0119 avatar autora wpisu, a nie komentuj\u0105cego.<\/p>\n<p>Plik comments.php:<\/p>\n<pre><code>&lt;div class=&quot;col-md-8&quot;&gt;\n\n  &lt;h3&gt;Komentarze:&lt;\/h3&gt;\n\n  &lt;?php cancel_comment_reply_link(); ?&gt;\n\n  &lt;form action=&quot;&lt;?php echo get_option(&#039;siteurl&#039;); ?&gt;\/wp-comments-post.php&quot; method=&quot;post&quot; id=&quot;commentform&quot;&gt;\n    &lt;div class=&quot;form-group&quot;&gt;\n      &lt;input type=&quot;text&quot; name=&quot;author&quot; id=&quot;author&quot; value=&quot;&lt;?php $current_user = wp_get_current_user();\n echo $current_user-&gt;user_firstname ?&gt; &lt;?php echo $current_user-&gt;user_lastname ?&gt;&quot;  class=&quot;form-control&quot; &lt;?php if ($req) echo &quot;aria-required=&#039;true&#039;&quot;; ?&gt; &gt;\n      &lt;label for=&quot;author&quot;&gt;Imi\u0119 &lt;?php if ( $req ) echo &quot;( wymagane )&quot;; ?&gt;&lt;\/label&gt;\n    &lt;\/div&gt;\n\n    &lt;div class=&quot;form-group&quot;&gt;\n      &lt;input type=&quot;email&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php $current_user = wp_get_current_user();\n echo $current_user-&gt;user_email ?&gt;&quot; class=&quot;form-control&quot; &lt;?php if ($req) echo &quot;aria-required=&#039;true&#039;&quot;; ?&gt;&gt;\n      &lt;label for=&quot;email&quot;&gt;Email ( &lt;?php if ( $req ) echo &quot;wymagane&quot;; ?&gt; )&lt;\/label&gt;\n    &lt;\/div&gt;\n\n    &lt;div class=&quot;form-group&quot;&gt;\n      &lt;textarea name=&quot;comment&quot; id=&quot;message&quot;&gt;&lt;\/textarea&gt;\n      &lt;label for=&quot;comment&quot;&gt;Tw\u00f3j komentarz (min. 15 znak\u00f3w)&lt;\/label&gt;\n    &lt;\/div&gt;\n\n  &lt;button class=&quot;submit&quot;&gt;\n  &lt;?php do_action( &#039;comment_form&#039;, $post-&gt;ID ); comment_id_fields(); ?&gt;Wy\u015blij komentarz&lt;\/button&gt;\n\n  &lt;\/form&gt;\n\n&lt;\/div&gt;\n\n      &lt;!-- Odwo\u0142anie si\u0119 do funkcji wygl\u0105du komentarzy z pliku functions.php --&gt;\n      &lt;?php wp_list_comments(\n        array(\n          &#039;type&#039;      =&gt;  &#039;comment&#039;,\n          &#039;callback&#039;  =&gt;  &#039;comments_feed_template_callback&#039;\n        )\n      ); ?&gt;<\/code><\/pre>\n<p>Plik function.php<\/p>\n<pre><code>function comments_feed_template_callback($comment, $args, $depth) {\n\n  $GLOBAL[&#039;comment&#039;] = $comment;\n\n  ?&gt;\n    &lt;div class=&quot;comment-display&quot;&gt;\n      &lt;a href=&quot;&lt;?php get_comment_author_url(); ?&gt;&quot; class=&quot;pull-left img-circle&quot;&gt;\n\n      &lt;? echo get_avatar( get_the_author_meta(&#039;user_email&#039;), $size = &#039;55&#039;); ?&gt;\n      &lt;\/a&gt;\n      &lt;div class=&quot;comment-content&quot;&gt;\n        &lt;h5 class=&quot;media-heading&quot;&gt;\n          &lt;a href=&quot;&lt;?php get_comment_author_url(); ?&gt;&quot;&gt;&lt;?php echo get_comment_author(); ?&gt;&lt;\/a&gt;\n          &lt;small&gt;&lt;?php comment_date(); ?&gt; o &lt;?php comment_time(); ?&gt;&lt;\/small&gt;\n        &lt;\/h5&gt;\n        &lt;?php comment_text(); ?&gt;\n        &lt;?php comment_reply_link(array_merge($args, array(\n          &#039;reply_text&#039; =&gt; __(&#039;&lt;strong&gt;Odpowiedz &lt;\/strong&gt;&lt;i class=&quot;icon-share-alt&quot;&gt;&lt;\/i&gt;&#039;),\n          &#039;depth&#039; =&gt; $depth,\n          &#039;max_depth&#039; =&gt; $args[&#039;max_depth&#039;]\n        ))); ?&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n    &lt;hr&gt;\n  &lt;?php\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-64613","topic","type-topic","status-publish","hentry","topic-tag-awatar-w-komentarzu","topic-tag-poprawny-kod"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/64613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/64613\/revisions"}],"wp:attachment":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=64613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}