zolyman
Member
Posted 2 years ago #
I have the next code for the recent comments widget.
<?php echo strip_tags($comment->comment_author); ?>: <a style="margin: 0 0 5px 0;" href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="on <?php echo $comment->post_title; ?>"><?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?>... </a>
Comment link does not lead me to comment right. Where is the problem?
This is the blog: http://blogaming.info (look in sidebar at "Comentarii recente" widget).
Ps: sorry for my english
zolyman
Member
Posted 2 years ago #
I tried already. It's not working.
zolyman
Member
Posted 2 years ago #
I tried this:
<?php $comments = get_comments('status=approve&number=5'); ?>
<div class="recentcomm">
<ul>
<?php foreach ($comments as $comment) { ?>
<li>
<div style="margin:0 10px 0 0;float:left;"><?php echo get_avatar( $comment, '35' ); ?></div>
<?php echo strip_tags($comment->comment_author); ?>: <a style="margin: 0 0 5px 0;" href="<?php echo get_permalink($comment->ID) . '#comment-' . $comment->comment_ID; ?>"><?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?>... </a>
</li><div style="clear:both;margin:0 0 5px 0;"></div>
<?php } ?>
</ul>
</div>
Still not working. Any ideas? Please, help me!
sdelamorena
Member
Posted 2 years ago #
Try with this (The same fragment of code):
<?php $comments = get_comments('status=approve&number=5'); ?>
<div class="recentcomm">
<ul>
<?php foreach ($comments as $comment) { ?>
<li>
<div style="margin:0 10px 0 0;float:left;"><?php echo get_avatar( $comment, '35' ); ?></div>
<?php echo strip_tags($comment->comment_author); ?>:
<a style="margin: 0 0 5px 0;" href="<?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID ?>"><?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?>... </a>
</li>
<div style="clear:both;margin:0 0 5px 0;"></div>
<?php } ?>
</ul>
</div>
Or replace the href content with the right comment link:
<?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID ?>
zolyman
Member
Posted 2 years ago #
Thank you!
It works with <?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID ?> at href.