About category-x.php file
Treść tego wpisu jest dostępna również w języku polskim
The most common purpose for creating and using category-x.php file is to exclude some category from showing on a front page. For example we have category ‘specials’ that can be viewed only after entering category itself but not on the main page.
First we create new file. We copy content of index.php to editor and save it as category-x.php where x is an ID of category ‘specials’. We need to put that file inside folder with theme we use. Then in index.php just bellow <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> we need to add <?php if (in_category('x')) continue; ?>. And that’s all. Any entry from category ‘special’ won’t show up on front page ;).
But we can use that file to change number of posts displayed on a page for one category only.
NOTE! There is a plugin called Custom Query String which enables to vary number of post being displayed on every page (author, archive, category, year, month, day, search, feed, home). However ALL categories will have the same number of post being displayed.
Let’s say we want to have 5 posts only displayed in category ‘extras’ while on other categories pages 10 posts can be seen. Just as I described above we create category-x.php file. In this case we DON’T need to change anything in index.php file. In category-x.php just above <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> we need to add:
<?php if (is_category()) { $posts = query_posts($query_string . '&orderby=date&showposts=5'); } ?>
And done. When we browse through category ‘extras’ on each page we can see 5 posts only.
19th October 2007 2 comments





I am using BlueSense theme but this didn’t work for me because it didn’t have category.php file but i found another way on this website
http://www.ipeat.com/?page_id=91
it has a plugin specially designed for the purpose, hope it helps.
Thanks for help link!
) has built-in category-x.php file. You need to create it by yourself.
Actually none of themes I know (and I know quite a lot of them