How to: Display only one sticky post on your homepage

Do you use WordPress as a CMS instead of a blog? If yes, you’ll probably be interested to know how you can display a single post on your blog homepage.

Open your index.php file, and replace your current loop by this one (replacing the stickies category name by the category of your choice) by :

<?php if (have_posts()) :
$my_query = new WP_Query('category_name=stickies&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>

That's all! Only the latest post is displayed on your homepage.

Leave a Comment

* Name, Email, Comment are Required