admin管理员组

文章数量:1128994

I've googled this issue and can't seem to find a solution...

In the comments, I'm trying to remove the hyperlink from the comment date/time where when you hover over the comment date, it hyperlinks (example /#comment-210) to the following comment...

What can I put in functions.php to just remove the link, I want to keep the date/time text..

I've googled this issue and can't seem to find a solution...

In the comments, I'm trying to remove the hyperlink from the comment date/time where when you hover over the comment date, it hyperlinks (example /#comment-210) to the following comment...

What can I put in functions.php to just remove the link, I want to keep the date/time text..

Share Improve this question asked Jun 25, 2019 at 3:57 Liquid_Shane_OLiquid_Shane_O 391 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

To keep the date/time text, you have to do minor modification in comments.php just add call back argument in wp_list_comments function.

<?php
  wp_list_comments( array(
      'callback' => 'custom_format_comment_listing'
  ) );
?> 

Then add Following code in your functions.php file. you can modification other html as per your design.

<?php
function custom_format_comment_listing($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
          <div class="comment-author">
            <?php echo get_avatar( $comment, 56 ); ?>
            <?php printf(__('<div class="fn">%s</div> <span class="says">says:</span>'), get_comment_author()) ?>
          </div>
          <div class="comment-moderation">
              <?php if ($comment->comment_approved == '0') : ?>
                 <p><?php _e('Your comment is awaiting moderation.') ?></p>
              <?php endif; ?>
          </div>
          <div class="comment-meta commentmetadata">
            <p ><?php printf(__('%1$s at %2$s'), get_comment_date('j F, Y'),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?></p>
          </div>
          <div class="user-comment">
            <?php comment_text() ?>
          </div>
          <div class="reply">
             <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
          </div>
     </div>
<?php } 
?>

Let me know if this works for you!

本文标签: commentsphp keep comment datetime but remove datetime39s hyperlink