So there is a little code that you can use to query the posts then show the last post on a page. in this particular code we are ordering by date and grabbing the last post that was made according to the date.
The following code will grab:
- The Permalink
- The title
- The Excerpt
- The Featured image
<?php $the_query = new WP_Query( 'posts_per_page=1&order=DESC&orderby=date' ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div class="entry"> <a href="<?php echo get_post_permalink();?>"> <h3><?php the_title(); ?></h3> <?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo '<img src="'.$feat_image.'"/>'; ?> <?php the_excerpt(); ?></a> </div> <?php endwhile; wp_reset_postdata(); ?>
I hope you enjoyed the article. If I was able to help you please consider a tip for the content.
One Time Tip