コメントのアバターを投稿者名で変更したいのですが、次のコードを書いても同じアバターしか出力してくれず困っていますにだ。
▼【functions.php】
→「gravatarToID」を作るにだ
function gravatarToID($id="名無しにだ", $size=64, $type="identicon") { $hashid = md5(md5($id)); if ($size > 512) { $size = 512; } $img = "<img src=\""; $img .= "http://www.gravatar.com/avatar/"; $img .= $hashid; $img .= "?d="; $img .= $type; $img .= "&?s="; $img .= $size; $img .= "\" width=\""; $img .= $size; $img .= "\" height=\""; $img .= $size; $img .= "\" alt=\""; $img .= $id; $img .= "\" title=\""; $img .= $id; $img .= "\" class=\"comment-avatar\" />"; echo $img; }
▼【content-custom.php】
→「gravatarToID」を書いて記事投稿者のアバターを出力したいけどできないにだ。
<div class="entry-content"> <div class="comment-author vcard"> <?php gravatarToID($comment->comment_author, 96, 'identicon');?> <b class="fn"> <?php echo esc_html( $post->txt_name ); ?> </b> </div> <div class="comment-content"> <?php the_content(); ?> </div> </div><!-- .entry-content -->
さらに、返信部分は次のコードなのですが、「wp list comments」にはアバターを指定する方法がないようで、上の【content-custom.php】のように「gravatarToID」を書くことができませんにだ。
▼【comments.php】
→記事へのコメント者や返信者のアバターを出力したいけど「gravatarToID」を指定する方法がないにだ。
<?php if ( have_comments() ) : ?> <ol class="comment-list"> <?php wp_list_comments( array( 'style' => 'ol', 'max_depth' => '20', 'per_page' => '100', 'avatar_size'=> 96, 'reply_text' => 'コメント', 'short_ping' => true, 'reverse_top_level' => true, 'reverse_children' => true ) ); ?> </ol><!-- .comment-list --> <?php endif; // Check for have_comments(). ?>
どうしたらうまいことできるか、ご存じの方がいらっしゃいましたらご教示いただきたく質問いたしましたにだ。何卒!よろしくお願いいたしますにだ。(>_<)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。