Use a single category as your front page in WordPress – Twenty Twelve theme example

This week I finally launched my personal blog. I decided to keep it as simple as possible and use the Twenty Twelve theme which comes with WordPress and I actually like quite a lot.

After an hour of real hard thinking about the structure of my pages and menus, I decided that I wanted to show the posts from only one of my categories on the front page. At that point, it seemed like a pretty regular choice and I expected to find such option in the Twenty Twelve’s Customize menu. It turns out I was wrong.

Quick explanation for advanced users:

Open your index.php file and add the line of code below before the beginning of the Loop. Change the number 7 with the ID number of your category. Code to add:

<?php query_posts($query_string . '&cat=7'); ?>

Detailed explanation for beginners:

1. Check your category’s ID.

Go to your back-end ( Under Posts -> Categories open your category for editing and look at the address bar of your browser. In the string up there you will have a part saying “ID=7″. It was 7 for me, but it will be another number for you, memorize it.

2. Open your theme’s index.php file.

To do that,  in wp-admin go to Appearance -> Editor; on the right side under Templates click on index.php (Main Index Template)

Note: If you are using a Child theme (recommended) you might not see the index.php file. If so, you have to create a copy of the index.php file in your Child theme’s folder. This is done through your FTP Client (eg. FileZilla) – just download the file from Twenty Twelve’s folder (usually: public_html/yoursite/wp-content/themes/twentytwelve) and then upload it to your Child’s theme folder.

3. Find the lines with this code:

<?php if ( have_posts() ) : ?>
    <?php /* Start the Loop */ ?>

4. Between those two lines add the following code:

<?php query_posts($query_string . '&cat=7'); ?>

Important: change the number 7 in ‘&cat=7′ with the ID number of your category that you remember from step 1.

5. Hit Update File and you are done. Check your front page and be happy.

If you don’t see anything on your front page, make sure you have at least one post in the category you are using.

Guest blogger: Stanimira