Hey, I’m using the following code for a custom slider, but I’m not able to get the post thumbnail image. I have tried with many functions but nothing worked out. Everything else is working, just the thumbnail image is an issue. If you can help me, it would be really nice.
The code is:
function last_posts( $object ) {
$args = array( 'numberposts' => '5' );
$recent_posts = get_posts( $args );
echo '<ul class="newsbox clear">';
foreach ( $recent_posts as $recent ) {
setup_postdata($recent);
echo '<li><a class="title" href="' . get_permalink($recent) . '">' . get_the_title($recent) . '</a><span class="img"><img alt="alt" src="/images/img.jpg" width="340" height="191"></span><span class="posted">Published on: ' . get_the_date('d.m.Y',$recent) . '</span><span class="text">' . get_the_excerpt($recent) . '</span></li> ';
}
echo '</ul>';
wp_reset_postdata();
}
add_shortcode( 'last5posts', 'last_posts' );