1

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

<?php
$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>
        </div>
    </div>
1
  • get_relative_date() isn't a core WordPress function. Is it one you wrote of from your theme or a plugin? Commented Jan 26, 2018 at 4:08

1 Answer 1

0

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

2
  • 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
    Commented Jan 29, 2018 at 0:08
  • Both should work actially.
    – swissspidy
    Commented Jan 29, 2018 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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