How To Include Recent Latest WordPress Posts In My Site Home Page

Here you can easily insert / include / embed the recent or latest 3 or 5 or 10 posts from your wordpress blog to your website home page or index.php page.

Please remember that you need to change your website home page from index.htm to index.php if any…

then in the top of the index.php pahe of your main website where you want to display the recent posts, simply paste this code.

remember at the top..

<?php
require('/the/path/to/your/wp-blog-header.php');
?>

<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

Now, paste the below code exactly where you want to display the post headers or headings.
// Post latest and last 10 posts.
<?php
require('/the/path/to/your/wp-blog-header.php');
?>

<?php query_posts('showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
<?php endwhile;?>

Note:

require('/the/path/to/your/wp-blog-header.php');

the above line, is important. please put the [path to your wp-blog-header.php page in your blog root directory.

 

Leave a Reply

Your email address will not be published.

You May Also Like