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

Please follow and like us:

10 thoughts on “Add latest blog posts to homepage

  1. Pingback: Jussy
  2. You may want to check out the script called CARP from geckotribes – its an RSS parser. Using that script, you can display feeds from several different sites in a variety of configurations.

    CARP is the free version and only displays RSS2 feeds. If you need to display ATOM or RSS1 feeds, check out GROUPER – its a commercial grade feed parser.

    With either of those scripts, you can display feeds from sites like CNN, Yahoo News, BBC, Foxnews. That way your site will stay updated with a variety of information.

  3. Thanks for sharing
    Was having some trouble with finding something like this until I came across this site. Thanks once again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.