0

I guess this is really simple for you guys but I have been trying to make this work for hours now and have yet to succeed.

I am trying to modify the comments template for a WordPress theme. All I want to do is add a specific piece of PHP code so that the avatar of the user in the comments section will have a link.

The original code to display the avatar in WordPress is:

<div class="comment-avatar"><?php echo get_avatar( $comment, 65 ); ?></div>

All I need to do now is add the following PHP code to the above line:

<a href="'.$userpro->permalink( $comment->user_id ).'">' XXX </a>

XXX is where the first line of code should go. Since this is a mix of PHP and HTML, I get very confused.

Can any of you guys please help me out on this one? I would appreciate it a lot :)

2
  • 2
    Have you tried <div class="comment-avatar"><a href="<?php echo $userpro->permalink( $comment->user_id ); ?>"><?php echo get_avatar( $comment, 65 ); ?></a></div>? Commented Aug 22, 2015 at 20:22
  • Thanks a lot :) It worked! Commented Aug 22, 2015 at 21:01

2 Answers 2

1

This is what you are trying to do

<a href="<?php echo $userpro->permalink( $comment->user_id )?>">
    <div class="comment-avatar"><?php echo get_avatar( $comment, 65 ); ?></div>
</a>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! It worked :) But I used Charlotte Dunois solution since it <a> tag is inside the <div> tag, making it more clean :) But thanks a lot for all your help, guys!
0
echo '<a href="'.$userpro->permalink( $comment->user_id ).'"><div class="comment-avatar">' . get_avatar( $comment, 65 ) . '</div></a>';

2 Comments

I am not sure what you mean, the answer was php code that the user requested
Your answer would me more useful if you edit it to explain how it works and why it answers the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.