How to make WP show only 1 post in the front page?
September 26th, 2007 Web Design, Wordpress 1,235 Views Add commentFirst you’ll need to make a copy of the index.php file in your theme directory. Rename this file home.php. This file will take precedence over index.php and be used for the front page display. Now, at the top of this file, you’ll need to make a call to query_posts, and that’s what i used in my last WP theme Orange Glossy.
- <?php
- get_header();
- query_posts(’posts_per_page=1′); //returns only the front page
- ?>
instead of
- <?php get_header(); ?>
We’re using the posts_per_page parameter to request that only a single post is retrieved and populated into the query object for The_Loop. So why not change the reading options in the WP Admin panel? The reason is because this will also affect the pagination for searches and archives. Query_posts offers a simple, elegant solution to this problem. And you can easily change the number of posts per page by changing the (’posts_per_page=1′) to any number you want.
Related Articles:




March 12th, 2008 at 9:05 am
I can’t believe how many people make this simple requirement so over complicated.
Thank you for your simplesolution!
Kind Regards
Jamie