I'm having trouble making the thumbnail and permalink of the most recent post appear on my blog's home page. I made the following code:
<?php
$posts_noticias = get_noticias_posts();
$destacado = array_shift($posts_noticias);
?>
<div id="noticia_destacada">
<a href="<?php the_permalink() ?>">
<?php the_post_thumbnail(array(495, 368, true)); ?>
<span class="data_noticia"><?php echo $destacado->post_date ?></span>
<h3 class="title_destacada"><?php echo $destacado->post_title ?></h3>
<?php echo $destacado->post_excerpt ?>
</a>
</div>
The code for the get_noticias_posts () function is as follows:
function get_noticias_posts($number = 5){
$args = array(
'posts_per_page' => $number,
'offset' => 0,
'category' => get_cat_ID( 'noticias' ),
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true );
$posts_array = get_posts( $args );
return $posts_array;
}
However, the displayed image and the permalink I placed on it are not from the last post but from an older post, from days ago. The most recent post date, title, and excerpt appear normally.
I can not figure out where in the code I went wrong. Could you help me?