• 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: https://blogaming.info (look in sidebar at “Comentarii recente” widget).

    Ps: sorry for my english

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter zolyman

    (@zolyman)

    I tried already. It’s not working.

    Thread Starter zolyman

    (@zolyman)

    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!

    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 ?>

    Thread Starter zolyman

    (@zolyman)

    Thank you!

    It works with <?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID ?> at href.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Comment link’ is closed to new replies.