WordPress: Displaying your latest blog post on a static page
Here is the simple and handy snippet of code that I use to display a WordPress blog’s most recent post on a static home page.
<?php $args = array( 'numberposts' => 3 ); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endforeach; ?>
You can see an example of this in action at one of the websites I designed – CrandallCoffee.com.
If you are trying to display your most recent post on a web page of a completely separate website (not a WordPress website), please take a look at how to do this in my post Displaying WordPress Posts on a Separate Web Page.
And, as always, let me know if you have any questions about this.