Forums

Show date/time differently and show comments on posts (2 posts)

  1. rob_the_villain
    Member
    Posted 1 year ago #

    Hi all,

    I'm currently trying to show the last 5 posts in date order with the code below:

    <?php $postslist = get_posts('numberposts=5&order=ASC&orderby=date'); foreach ($postslist as $post) : setup_postdata($post);?>
    		<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
     		<?php the_date(); ?>
     		<?php endforeach; ?>

    The problem is that I want to date/time to be shown slightly differently, more like this:

    Title of post 5
    20 minutes ago | 5 comments

    Title of post 4
    1 day ago | 5 comments

    Title of post 3
    3 days ago | 5 comments

    Title of post 2
    1 week ago | 5 comments

    Title of post 1
    1 month ago | 5 comments

    Also, how is it possible to show the amount of comments on each post?

    Cheers

  2. rob_the_villain
    Member
    Posted 1 year ago #

    Solved!

    <?php $postslist = get_posts('numberposts=5&order=ASC&orderby=date'); foreach ($postslist as $post) : setup_postdata($post);?>
    		<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
     		<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?> <?php comments_number('No Comments', '1 Comment', '% Comments' );?>
     		<?php endforeach; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic