0
votes

I'm making a custom theme in Wordpress, and I want that theme to show a home page displaying the latest (only one) post of a certain category previously created. Lets' say this category is called: "specificcategory".

I made my home.php template-file and put that function in it:

<?php query_posts('posts_per_page=1'); ?>
            <?php if (have_posts()) : while(have_posts()) : the_post();?>
                    <?php the_content();?>
            <?php endwhile; endif;?>

I hope it would show the latest post (so it does) but not of the specific category, it's just displays the latest post of any category.

PS: I already have an archive-specificcategory.php created and used to display the list of this specific category posts.

So what did I do wrong?

1

1 Answers

0
votes

Change your query to query_posts( 'posts_per_page=1&cat=1' ) where 1 is the ID of the category you want.

See this section of the official code ref.