Add custom fields for wordpress categories
While we were developing a website for a client based on Wordpress CMS, we needed to add several custom fields but for Wordpress categories. Since Wordpress doesn’t have native support for adding custom fields to categories we needed a plugin. I googled couple of hours trying to find the plugin but had no luck so we decided to develop it.
At this stage it’s has vary basic functionality. You can define infinite key=>value pairs for each category and also supports WYSIWYG editor if you need (x)HTML. We plan to implement image upload, in case you need to “attach” images or icons within your categories, in feature versions. It can be used also to define custom title, description and keywords tags for example.
INSTALLATION
- 1. Unpack/upload the “category-fields” directory “wp-content/plugins/”.
- 2. Activate the plugin from the Admin interface; “Plugins”.
- 3. Go to “Options -> Category Fields” and create custom fields as necessary.
USAGE
- Returns an array of key->value pairs for current ($cat) category
1 2 3 4
<?php $cat_custom = get_cat_fields($cat); print_r ($cat_custom); ?>
- Display single value for key_name for current ($cat) category
1 2 3
<?php echo get_cat_fields($cat, 'key_name'); ?>
Supports Wordpress 2.3+
Related posts:



Hello,
I plan to developp a wordpress site and I was looking for this functionnality. The next way is to add custom fields to “tags” and (why not) to “archives”. In point of SEO, it will be good to make each page of the blog different; by adding a description, an image, some extern rss, internal links…
March 4th, 2008 at 8:29 amDoesn’t work for WP233.
March 5th, 2008 at 10:05 pmTo complete my precedent post, it finallly seems to work after modifying category_fields.php
March 5th, 2008 at 10:20 pmI change line 194:
function cat_fields_rows($parent = 0, $level = 0, $categories = 0) {
global $wpdb, $class, $user_level;
if (!$categories)
with:
function cat_fields_rows($parent = 0, $level = 0, $categories = 0) {
global $wpdb, $class, $user_level;
$user_level=4;
if (!$categories)
in order to make work line 211.
Looks fine!
hi…can someone post a detailed how to use this plugin! this plugin sounds good, but i have nooooo idea to use it. wo what to do in the option-panel?
March 18th, 2008 at 10:03 pmi have several custom-fields, now i want to add the new post, with the custom-fields, automatic to custom-field-categories…
@ Djoudje
We have tested it with WP 2.3.3 and works fine. It can be a conflict with another plugin you have installed. If you don’t mind showing us the error it produces (before your fix).
@ toul
It’s pretty straightforward but you must have some basic PHP knowledge to use it. If you provide some details maybe I can have a look and possibly help
Cheers!
March 18th, 2008 at 11:18 pmthank you for your response…
March 19th, 2008 at 12:02 am1st: i have created some custom fields with The Ultimate WordPress CMS Plugin - Fresh Post
2nd: Now, i thought i can use your plugin to “put” the post automatic to categories named after the custom fields.
for example: i write a post with the custom field “name” and the value “steven”. now i want that this post will shown in the categorie “steven”.
of course i know, that i can use the categorie panel, but for some reasons i want to “automate” this process…
@ toul
I think you mixed the ins and outs… To clarify…
Custom category fields plugin is useful when you want to add “static” content to your categories only. For example, lets say you are creating a coupon website using WP CMS and you need to organize coupons (posts) within affiliate shops (categories). You probably need, for each shop (category), to enter: short description; website screenshot; shop logo; additional info; etc…
This is where the custom category fields plugin comes handy, as entering such “static” info for each category is not possible otherwise.
Hope this helps
March 19th, 2008 at 9:03 amThe installation was ok, but in the admin panel, the options “manage” and “delete”(?, i don’t exactly remember) didn’t appear in the table. Only, category names appear. The bug was just because of user level, although i am admin on the site.
April 2nd, 2008 at 7:49 pmI have problem. I use exec-php plugin and thins plugin does’t allow the use of wysiwyg and i disable it in my user profilw but when i use this plugin wysiwygt donĀ“t disappear. How remove wysiwyg from this plugin.
April 5th, 2008 at 11:11 amSorry my bad englisgh