[resolved] How to remove hyperlink from comment date? (4 posts)

  1. deko
    Posted 5 years ago #

    When wp_list_comments() is called from comments.php, it formats the date of each comment as a hyperlink.

    I don't want the date to be a hyperlink. Is there anyway to prevent this?

    It looks like wp_list_comments() is defined in wp-includes/comment-template.php, but I'm not sure how to modify it to eliminate the date hyprelink formatting.

    Is there an easier way?

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    See http://codex.wordpress.org/Function_Reference/wp_list_comments - especially the details about comment callbacks.

  3. deko
    Posted 5 years ago #

    thanks esmi. after reading that page, my impression is that the wp developers hardcoded hyperlinked comment dates in order to provide permalinks to comments.

    reasonable enough. perhaps I should simply style the link so it doesn't look like a link.

    for those who *really* don't want hyperlinked comment dates, line 1362 to line 1637 of wp-includes/comment-template.php can be modified to this:

    <div class="comment-meta commentmetadata">
      <?php printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?>
      <?php edit_comment_link(__('Edit'),'  ','' ); ?>

    which removes the following line of code:

    <a href="<?php //echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">

    along with the closing </a> in the following line.

    this will prevent comment dates from being hyperlinked.

  4. Patty
    Posted 5 years ago #

    @deko - Thank you so much for this tip! I spent hours trying to figure this out before I found your post! Your tip worked perfectly!

Topic Closed

This topic has been closed to new replies.

About this Topic