• 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

Viewing 1 replies (of 1 total)
  • Thread Starter rob_the_villain

    (@rob_the_villain)

    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; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Show date/time differently and show comments on posts’ is closed to new replies.