Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Call different archive page for category WordPress

  • SOLVED

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.

Thank You

Answers (4)

2011-12-13

Arnav Joy answers:

try creating a page named as category-1.php

write all your code in this php file .

2011-12-13

Ivaylo Draganov answers:

Hi,

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

2011-12-13

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.

2011-12-13

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; ?>