You don’t generate a WP Loop using wp_get_recent_posts()
so get_the_time()
won’t pull the post date. The post date is available within the array wp_get_recent_posts()
returns though: $recent['post_date']
. Or you can use the modified date: $recent['post_modified']
.
This works (tested on my dev site):
<?php
$args = array(
'post_status' => 'publish',
'numberposts' => '30',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-aside',
'operator' => 'NOT IN'
),
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-image',
'operator' => 'NOT IN'
)
)
);
$recent_posts = wp_get_recent_posts( $args );
?>
<div class="sidebar-entries">
<?php
foreach( $recent_posts as $recent ){
echo '<div class="sidebar-entry">';
echo get_the_post_thumbnail( $recent['ID'], 'sidebar-thumb', array( 'class' => 'sidebar-image' ) );
echo '<div class="sidebar-entries-title">';
echo '<a href="' . get_permalink( $recent["ID"] ) . '">' . __( $recent["post_title"] ) . '</a>';
echo '<span class="posted-on">' . human_time_diff( strtotime( $recent['post_date'] ), current_time('timestamp') ) . ' ago </span>';
echo '</div>';
echo '</div>';
}
?>
</div>
(A note though, don’t just copy/paste code from the Codex. If you don’t need the taxonomy argument in there, don’t include it.)