Hi, while my wordpress site uses a certain template for the archive pages, I would like my 'News' category (ID 1) to show a different archive template and style.
I have created 'archive-news.php' and have written a different layout and style for this category archive.
I know somewhere I need to put a code that says 'if is category 1 then show archive-news.php'
Can someone help me out with the code I need to use and where I should add it.
Ivaylo Draganov answers:
no need for any conditional checks - simply rename your <em>archive-news.php</em> to <em>category-news.php</em>("news" is the category slug) or <em>category-1.php</em>("1" is the category ID).
Check out [[LINK href="http://codex.wordpress.org/Template_Hierarchy#Category_display"]]WP's template hierarchy[[/LINK]] to learn more
Nilesh shiragave answers:
Create Template file with name "category-id.php" change id with your news category id.
Nilesh shiragave comments:
Just rename archive-news.php which you created to category-news.php
By doing this you don't have to add any additional conditional checks to check current category.
Charles Klycinski answers:
Or You can use is_category() for example in category themplate file:
<?php if (is_category('Category A')) : ?>
/* Themplate for Category A */
<?php elseif (is_category('Category B')) : ?>
/* Themplate for Category B */
<?php else : ?>
/* Themplate for other Cathegories */
<?php endif; ?>