tried different ways to implement without any success, Any help?

$recent_posts = wp_get_recent_posts(array(
    'numberposts' => 99, // Number of recent posts thumbnails to display
    'post_type' => 'post',
    'post_status' => 'publish' // Show only the published posts
foreach($recent_posts as $post) : ?>
    <div class="cards">
        <div class="card">
            <h4><?php echo $post['post_title'] ?></h4></a>
            <p class="card-text">Happened time ago</p>
            <p class="card-text">... <small><a href="<?php echo get_permalink($post['ID']) ?>"><i class="fa fa-eye"></i> Read more</a></small></p>
  • get_relative_date() isn't a core WordPress function. Is it one you wrote of from your theme or a plugin? – Jacob Peattie Jan 26 '18 at 4:08

You can use human_time_diff( get_the_time( 'U', $post ) ) and get_the_excerpt( $post ) for these two tasks.

  • Thanks for your response @swissspidy. So do you think I can replace: Happened time ago with <?php echo human_time_diff( get_the_time( 'U', $post ) )?> and ... with <?php get_the_excerpt( $post ) ?> ? Or I should use ( $post ['ID']) in both cases? – SuperAtic Jan 29 '18 at 0:08
  • Both should work actially. – swissspidy Jan 29 '18 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.