I'm working on a website - blah blah.
The category pages have image thumbnails for each post inside - and now I need to add content to the category pages. The way it has been designed is to have an introduction paragraph above the thumbnails, then the thumbnails which link to each post, and then more text underneath.
However, there are a lot of categories, so setting up a category template for each category is a lot of work, and not very future-proof. What would be ideal is if custom fields could somehow be added to the categories, or something like that.
Does anyone have any thoughts on how I could achieve this?
Thanks.
Dan Fraticiu answers:
A quick idea would be to separate the category description in two, something like a <strong>[split]</strong> tag. The in your category temaplate you'll have something like this:
...
$description = explode('[split]',category_description($cat_ID));
echo $descirption[0]; //your introduction paragraph
echo 'your list of pst thumbnails';
echo $description[1]; //the rest of the description
...
Or if you are positive you'll only ever have just one paragraph as introduction, you can split the description in the first paragraph and the rest of the text.
Utkarsh Kukreti answers:
Have a look at this - http://wordpress.org/extend/plugins/wp-category-meta/
Just found another one - http://coffee2code.com/wp-plugins/custom-fields-for-anything/ - was updated long time back, didn't test if it works with 2.9.2
Dan Davies comments:
Unfortunately this doesn't work with 2.9.2
Dan Davies comments:
Unfortunately that doesn't work either.
Laura Gentry answers:
I'm slightly confused about the question. Could you clarify: Is the problem that you don't know how to design a category template to show the pieces of content you want to show? Or have you already figured out that piece and your problem is that you don't know how to assign the sample template to multiple (or perhaps, every) category page? I can think of a couple ways to achieve the latter issue, just wanted to make sure I understand your question.
Laura Gentry comments:
If you're going to use the same layout for every category, just create a file named category.php in your active theme and Wordpress will use that file for any category archive page (that file name is given the highest precedence in the template hierarchy for category pages).
If you're going to use it for some categories, but not all, use Christian's example in category.php. But I would use the if statement to call another file for any special layout, like this:
<?php if (is_category('1')) : ?>
<?php
// call your special template here if you're in category 1
include(TEMPLATEPATH . '/category-special.php'); ?>
<?php elseif (is_category('2')) : ?>
<?php
// call your special template here if you're in category 2
include(TEMPLATEPATH . '/category-special.php'); ?>
<?php else : ?>
All the code for your default template would go here.
<?php endif; ?>
kjll kll answers:
Open the index.php or archive.php or category.php (whatever template is used displaying the category archives)
Use this code every time you want to show some category related content.
<?php if (is_category('1')) : ?>
Content you want do display for the category with ID 1
<?php elseif (is_category('2')) : ?>
Content you want do display for the category with ID 2
<?php elseif (is_category('X')) : ?>
Content you want do display for the category with ID X
.
.
.
<?php else : ?>
Content for all other categories
<?php endif; ?>
In my opinion adding some lines of code to the template file for each category while by while...