Add latest blog posts to homepage

Reading Time: < 1 minute

You have a blog at domain.com/blog and would like for the latest blog posts to appear on domain.com. To be able to perform this action, follow the instructions below:

1) Copy the below script to where you wish the latest post to appear. Remember to amend add path to.
2) Amend numberposts=5 to the number of posts you require to appear on the homepage.
3) The below code will display the post title, linked back to your post. It will also display a short 55 word summary.

<?php
require(‘/add/path/to/wp-blog-header.php’);
?>

<?php
$posts = get_posts(‘numberposts=5&order=ASC&orderby=post_title’);
foreach ($posts as $post) : start_wp(); ?>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to<?php the_title(); ?>”><?php the_title(); ?></a>  
<?php the_excerpt(); ?>
<?php
endforeach;
?>

What if you want to increase the default 55 worded summary?

1) Open formatting.php located within the folder wp-includes
2) Locate the code  $excerpt_length = 55;
3) Amend the number as required