[Plugin: Timeago] Same "time ago" for all comments (1 post)

  1. lukeshumard
    Posted 5 years ago #

    I'm trying to use the plugin Timeago to display the time of comments, but it seems to keep displaying the same amount of time difference for each comment. It says that each of my comments is two days old, which is not true for any of them. I'm wondering if this is because I'm using a foreach statement to get my comments. Here is my code...

    <?php $args = array('number' => 5, 'status' => 'approve');
    $comments = get_comments($args);
    foreach($comments as $comment) {
    $commentcontent = $comment->comment_content; ?>
       <div class="comment"><?php echo $commentcontent; ?>
          <span class="time"><?php the_time_ago(); ?></span>
    <?php }?>

    I also tried putting this in the foreach statement as an attempt to get the time for each comment as opposed to just one (since they all displayed with the same time ago), but all this did was put the_time_ago(); above each comment because of the way it's function is written.

    $commenttime = the_time_ago();

Topic Closed

This topic has been closed to new replies.

About this Topic