Popular Tags
Feb
21st

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.

Download plugin

INSTALLATION

  1. 1. Unpack/upload the “category-fields” directory “wp-content/plugins/”.
  2. 2. Activate the plugin from the Admin interface; “Plugins”.
  3. 3. Go to “Options -> Category Fields” and create custom fields as necessary.

USAGE

  1. 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);
    ?>
  2. 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:

9 Responses to “Add custom fields for wordpress categories”

  1. Djoudje says:

    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…

  2. Djoudje says:

    Doesn’t work for WP233.

  3. Djoudje says:

    To complete my precedent post, it finallly seems to work after modifying category_fields.php
    I 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!

  4. toul says:

    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?
    i have several custom-fields, now i want to add the new post, with the custom-fields, automatic to custom-field-categories…

  5. Milos says:

    @ 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!

  6. toul says:

    thank you for your response…
    1st: 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…

  7. Milos says:

    @ 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 :)

  8. Djoudje says:

    The 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.

  9. theworst says:

    I 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.
    Sorry my bad englisgh


Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>