Limiting the number of posts on home page
Posted: Tue Jul 05, 2011 8:03 am
Hi,
I am working on a blog and following the blog tutorial I was able to come to a good point. Now, I want to limit the number of posts on the home page (5 for example). How Can I do that?
Currently I have the following code in my index.php file:
I am working on a blog and following the blog tutorial I was able to come to a good point. Now, I want to limit the number of posts on the home page (5 for example). How Can I do that?
Currently I have the following code in my index.php file:
<?php foreach($posts as $post) { ?> <h1><a href="<?php echo $post['post_name']; ?>"><?php echo $post['post_title']; ?></a></h1> <p>Posted by <strong><?php echo $post['post_author']; ?></strong> on <?php echo date('j M, Y', strtotime($post['post_date'])); ?> in <strong><a href="category.php?p=<?php echo $post['cat_name']; ?>"><?php echo $post['cat_title']; ?></a></strong> </p> <div> <?php echo $post['post_body']; ?> </div> <?php } ?>I tried using something like for ($i = 1; $i <= 5; $i++) but it didn't work.