Custom Meta for new Taxonomies in WordPress 3.0

July 7th, 2010 @ 8am : 54 comments : Socialize This
Filed Under: Tags: , , , , ,

I’ve been playing around with the new options in WordPress 3.0 like the new Menu system and Custom Post types. These are fantastic additions to the WordPress engine. The guys who work on WordPress core really deserve a big hand.

One other item which gets less attention are Taxonomies. When you initiate a new Taxonomy you are basically cloning the existing Post Category or Post Tags logic. With Post Categories you are provided an additional field for parent because post categories are hierarchal. But what if you want to add additional fields to the interface? This is what I intent to disclose in this article.

Before we get into the code example let me provide some background. I’m working on a custom shopping cart for a client. I intent to support the shopping cart system using a Custom Post Type and 3 Custom Taxonomies. The Custom Post Type will be called ‘Products’. Within Product we have at least 3 new Taxonomies. These are ‘Product Categories’, ‘Product Tags’ and ‘Product Packages’. The ‘Product Categories’ and ‘Product Tags’ function similar to the Post Categories and Post Tags but are used for the Products. The third Taxonomy, ‘Product Packages’, is a little more special. A ‘Package’ in terms of the shopping cart functionality will contain information related to the product configurations. For the client a Product is a photograph and is sold in different formats as in 8 x 10 Print, 8 x 10 Matted and Framed Print, Xmas Cards, etc. You may be thinking these are are just categories and you would be correct. The WordPress Taxonomies support 4 basic fields of information Name, Slug, Parent and Description. For the ‘Product Packages’ Taxonomy I also need to store extra fields such as Active status, Unit Sale Price, Unit Ship Price and Unit Quantity.

Here is a screenshot of the actual Product Package detail.

WordPress Taxonomy Meta fields

Here is the simple code to define the new Taxonomy ‘Product Packages’. I’ve wrapped this in my init function to make it easier to use.

1
2
3
4
5
6
7
8
9
10
add_action( 'init', 'product_init' );
function product_init()
{
    register_taxonomy( 'product_packages', 'products',
        array(  'hierarchical' => true,
                'label' => __('Product Packages'),
                'query_var' => false
        )
    );
}

Now we want to hook into some actions created by WordPress when the new Taxonomy is registered. The first action is used to insert extra fields to the Taxonomy item edit form. Note that all Taxonomies offer the quick edit and the full edit form. This is for the full edit form only.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
add_action( 'product_packages_edit_form_fields', 'edit_product_packages', 10, 2);
function edit_product_packages($tag, $taxonomy)
{
    $product_package_active = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_active', true);

    // Check/Set the default value
    if (!$product_package_active)
        $product_package_active = "Yes";

    $product_package_unit_price = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_unit_price', true);
    $product_package_ship_price = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_ship_price', true);

    // Check/Set the default value
    $product_package_ship_unit = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_ship_unit', true);
    if (!$product_package_ship_unit)
        $product_package_ship_unit = 1;

    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="product_package_active">Package Active?</label></th>
        <td>
            <select name="product_package_active" id="product_package_active">
                <option value="Yes" selected="selected">Yes</option>
                <option value="No" <?php
                    if ($product_package_active == "No") echo ' selected="selected";'; ?>>No</option>
            </select>
            <p class="description">Marking a Package to 'No' will hide all items in that package.</p>
        </td>
    </tr>

    <tr class="form-field">
        <th scope="row" valign="top"><label for="product_package_unit_price">Package Unit Price?</label></th>
        <td>
            <input type="text" name="product_package_unit_price" id="product_package_unit_price"
                value="<?php echo $product_package_unit_price; ?>"/><br />
            <p class="description">This is the unit price for the items in this 'package'.</p>
        </td>
    </tr>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="product_package_ship_price">Package Shipping Price?</label></th>
        <td>
            <input type="text" name="product_package_ship_price" id="product_package_ship_price"
                value="<?php echo $product_package_ship_price; ?>"/><br />
            <p class="description">This is the cost per unit to ship the products in this package.</p>
        </td>
    </tr>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="product_package_ship_price">Package Shipping Unit</label></th>
        <td>
            <input type="text" name="product_package_ship_unit" id="product_package_ship_unit"
                value="<?php echo $product_package_ship_unit; ?>"/><br />
            <p class="description">This is the quantity of product items. Normally this will be 1. For cards this number may be 6 or 8.</p>
        </td>
    </tr>
    <?php
}

Let’s break down the code some. The ‘add_action’ is a built-in WordPress function. The first parameter ‘product_packages_edit_form_fields’ is a dynamic action key which is created based on the Taxonomy key + ‘_edit_form_fields’. In our case the Taxonomy key is ‘product_packages’. This action is executed from the WordPress file wp-admin/edit-tag-form.php line 68. There is also another action on line 67 which is more generic ‘edit_tag_form_fields’. But we are only concerned with the edits for our Taxonomy. From edit-tag-form.php line 68 you can see the action will pass your function two argument the Tag being edited and the Taxonomy. So our function ‘edit_product_package’ also supports two arguments passed into it. Though we really don’t need or do anything with the second argument since we know this is our specific Taxonomy ‘product_packages’.

Inside the function we call the new WordPress function ‘get_metadata’ to load in the meta items we will be adding to the bottom of the item edit form. This function replaces the get_post_meta function. Actually if you review the get_post_meta function in wp-includes/post.php line 1196 you will see if calls the get_metadata function. The new get_metadata function takes the same basic arguments. The big difference is the first parameter which needs to be a valid Taxonomy. In our case we pass in the Taxonomy ‘product_packages’. Once we have loaded all the item meta information we then display the table row which contain our new form fields. PRetty simply.

Next we add another action hook. This one will activate when the user saves the Taxonomy item. Here is the action code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
add_action( 'edited_product_packages', 'save_product_packages', 10, 2);
function save_product_packages($term_id, $tt_id)
{
    if (!$term_id) return;
   
    if (isset($_POST['product_package_active']))
        update_metadata($_POST['taxonomy'], $term_id, 'product_package_active',
            $_POST['product_package_active']);

    if (isset($_POST['product_package_unit_price']))
        update_metadata($_POST['taxonomy'], $term_id, 'product_package_unit_price',
            sprintf("%01.2f", $_POST['product_package_unit_price']));

    if (isset($_POST['product_package_ship_price']))
        update_metadata($_POST['taxonomy'], $term_id, 'product_package_ship_price',
            sprintf("%01.2f", $_POST['product_package_ship_price']));

    if (!isset($_POST['product_package_ship_unit']))
        $_POST['product_package_ship_unit'] = 1;
    update_metadata($_POST['taxonomy'], $term_id, 'product_package_ship_unit',
        $_POST['product_package_ship_unit']);
}

This action is similar to the previous action we discussed. But one gets initiated from wp-includes/taxonomy.php line 1970 and is called after the Taxonomy item has been updated in the database. The action key ‘edited_product_packages’ is again made up of ‘edited_’ + our Taxonomy key ‘product_packages’. Also like the previous action we tell the action we want to accept the maximum two arguments though we only really care about the first on. Inside the function ‘save_product_packages’ we check to make sure the ‘term_id’ was not empty. The rest of the function code simple checked if the $_POST variable was passed in from the form. And if it was the WordPress function ‘update_metadata’ is called with the Taxonomy key ‘product_packages’ and the updated value. Again the function ‘update_metadata’ replaced the function and works similar to ‘update_post_meta’.

That is pretty much it for the WordPress coding part. (keep reading)

Not quite. There is one other important topic to discuss. We need to create a new database table to contain out ‘product_packages’ term meta information. Let me explain why. You might have a guess that our ‘update_metadata’ function would store the fields into the wp_postmeta table. Well you would be a close guess but wrong. The function ‘get_metadata’ and ‘update’metadata’ use the Taxonomy key provided via the first function argument to interact with a specific database table. The name of the database is again determined based on the name of the Taxonomy from the first argument. In our case the table name will be something like ‘wp_product_packagesmeta’. Note this depends on your table prefix as defined in your site’s wp_config.php. See the similarity in the tables ‘wp_postmeta’ and our table named ‘wp_product_packagesmeta’? It is simply ‘wp_’ + Taxonomy key + ‘meta’. Again the ‘wp_’ table prefix will be different depending on your settings in your wp_config.php file for the variable ‘$table_prefix’.

Next we need to define the table structure. Again there is a similar pattern for the column names. If you examine the wp_postmeta table columns you will see the 4 columns meta_id, post_id, meta_key and meta_value. For our table the only change is the name of the second column. Instead of ‘post_id’ our column will be named ‘product_packages_id’. See the pattern? Taxonomy key + ‘_id’.

Instead of providing the exact SQL CREATE TABLE command I am only going to suggest you copy the wp_postmeta table of your current site.

My reasoning for not providing the SQL CREATE TABLE command are I don’t want some people to take this literal SQL command and breaking their system then blaming me.

Copy the table structure only and name the copy ‘wp_product_packagesmeta’. Then edit the table structure and rename the second column from ‘post_id’ to ‘product_packages_id’. Once you have the table created and ready you need to tell WordPress where to use it. In the init function ‘product_init’ we need to make two changes. At the top inside the function add the line ‘global $wpdb;’. Then at the very bottom of the function add the line ‘$wpdb->product_packagesmeta = $wpdb->prefix.”product_packagesmeta”;’. your final ‘product_init’ function should look like this

1
2
3
4
5
6
7
8
9
10
11
12
13
add_action( 'init', 'product_init' );
function product_init()
{
    global $wpdb;

    register_taxonomy( 'product_packages', 'products',
        array(  'hierarchical' => true,
                'label' => __('Product Packages'),
                'query_var' => false
        )
    );
    $wpdb->product_packagesmeta = $wpdb->prefix."product_packagesmeta";
}

Hope you enjoy this little tip. I’m already working on the next article which will build upon this one. The next article will show you how to customize the table list column when you list out the Product Packages items (see image below). Look for it soon.

WordPress Taxonomy meta listing

You can download all the code used in the article below:
codehooligans_wordpress_taxonomy_meta.zip

Both comments and pings are currently closed.

54 Responses to “Custom Meta for new Taxonomies in WordPress 3.0”

  1. mike van winkle Says:

    This is a great tutorial, thanks a million! One suggestion, instead creating a meta table for each taxonomy, would it make more sense to just create one table … “wp_termmeta”. To keep the clutter down. Also there’s a plugin that will create this table for you “Simple Term Meta”.
    [link:http://wordpress.org/extend/plugins/simple-term-meta/

    Not a huge deal but could make life a little easier.

  2. Paul Menard Says:

    @mike van winkle: Thanks for stopping by and leaving a nice detailed comment. My example was that of illustration for developers not really focused on how to override the new default WP function get/add/delete_metadata. True one could use the simple term meta plugin. But given this term meta table has the same structure as the already existing postmeta table why not just use it and then no need for a new table.

    I would rather keep things separated in the case of my custom taxonomies. That way if I decide to go another way I can just delete the one table not need to worry about filtering the table. Which on that note I think the simple term meta is a great plugin but it will cause issues down the road for users. Here is why. Look at the plugin function for add_termmeta().

    1
    2
    3
    function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
        return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
    }

    The plugin function is calling the WP function add_metadata with a hard-coded
    meta_type value of ‘term’. So months down the road if the user is using more than a few custom taxonomies with extended meta data they will all be all be stored into this one table. All with the type of ‘term’. How would you split this term information up if you were removing one of your custom taxonomies? Just a thought. Thanks again for the comment. I’m show many will appreciate the note about Simple Term Meta.

  3. Using Term Meta | wordHeavy Says:

    [...] my search, I stumbled upon this terrific tutorial from CodeHooligans and this simple plugin Jacob M Goldman. Both of which I rely on [...]

  4. Pedro Farinha Says:

    Very useful tutorial that serves perfectly for a project I’m currently working on, but I really need the second part of the article… When will the article be available?

  5. Paul Menard Says:

    @Pedro Farinha: Thanks for the comment. And thanks for reminding me that I promised another article on this thread. Look for this coming over the weekend. Probably sometime Sunday afternoon. The third article will deal with adding custom user roles to the system to manage access. Quite interesting.

  6. Adding Custom Meta Headers To Taxonomy Table Columns in WordPress 3.0 « CodeHooligans Says:

    [...] Custom Meta for new Taxonomies in WordPress 3.0 [...]

  7. 2046 Says:

    oki, thanks
    but how do you call up these meta in template?

  8. Paul Menard Says:

    @2046: Simple. Just use the get_metadata() WP function. This is very similar to the get_post_meta function. I can’t find a direct link to the function page in the WP Codex. The function is located in /wp-includes/meta.php around line 223. But here is the breakdown.

    $your_local_string = get_metadata(taxonomy, $term_id, $meta_key, true);
    $taxonomy = This is the Taxonomy key. The first parameter when you registered your taxonomy.
    $term_id = This is the ID of the term who’s meta you are trying to access.
    $meta_key = This would be your custom field meta key. This must match the same key value from when you updated the meta.
    true = This tell the function to return results as a single instead of array.

    Hope this helps.

  9. 2046 Says:

    i got it form your next post:(hope the code stays as it has to)
    echo get_metadata(‘taxonomy’, $term->term_id, ‘term’, true);

  10. 2046 Says:

    don’t you know how to add image chooser field.
    What I want to achieve is to have a link that call native pop-up window with media library and select the image form there as a thumb for taxonomy term.
    All I need is a id of that attachment. Based on that ID I can choose later on the appropriate size in template.

    thanks a lot 2046

  11. Paul Menard Says:

    @2046: Actually you can start with this fine plugin http://wordpress.mfields.org/plugins/taxonomy-images/ I found it last week looking to do the same thing. I’ve not had a chance to deconstruct the code. I’m curious how he is adding the Media Library popup to the category page also.

  12. 2046 Says:

    Yep, I found it too.
    I let you know if I’ll be able to go that deep.

    thx 2046

  13. David Says:

    Excellent! Thank you so much for the detailed code, comments and explanation. I used some plugins to create the fields, I just needed the ability to transfer custom fields to taxonomies.

    I haven’t finished cause my eyes are killing me. Any chance you might want to turn down the contrast a bit? Either make the text slightly darker or background slightly lighter? Just a thought. I’ll be back soon! Thanks again!
    Cheers!

  14. Paul Menard Says:

    @David: Thanks for the comment. Glad you are enjoying the article. As for the theme contrast I have a new theme in the works. Coming soon.

  15. Michael Fields Says:

    Paul,
    Thanks for the great article. This post along with another I found taxonomy metadata really came in handy a month ago on a site that I was building. I see that there was a mention of my taxonomy images plugin. Unfortunately, it does not use a custom meta table as you describe here. I coded it before I knew about this great feature. If/when a core termmeta table is added to WordPress, I’ll update the plugin to support this. Re-purposing the media uploader for the term pages was not all that easy and my solution is most likely not the best to be honest :)

  16. Chris Says:

    First of all, thanks for an excellent article… I have been looking for explanations on how these fields can be added. I do have a specific question though… would it not be possible to store all the metadata in the “description field” in an array thus avoiding an extra table? I am trying my best to keep things totally defaulted to the core wordpress tables. If this can be done but would have downsides compared to your suggested version by duplicating the table… could one please explain the reasons why this idea is not good or what benefits your approach has in comparison?

    Finally, I did read the comment above related to adding the ability to add media from the media library via a browse button… I would greatly appreciate if someone could share exactly how this is done for a specific taxonomy… please do share anyone…

  17. Paul Menard Says:

    @Chris: Thanks for the comment. Sure you can do whatever you want with the storage of the fields. I chose to illustrate what I felt was the more proper (and harder) way. Others on this post have commented that you can just store the meta information into the same table where posts/pages are stored. While this is a solution I don’t personally like it since it would muddle the data with the custom post type. I guess my thought was custom post types are not part of core so should not be stored within the core WP tables. This makes it much cleaner to remove the data is at some point I decided not to support that custom post type in the system any longer. Again, my goal was to illustrate the harder method or storage.

  18. The Frosty Says:

    This is awesome. Took me an hour or so to put together the correct database code. Found a useful source at shiba to help with that. Since I am created this for a theme, I needed the database created on activation. Still just 30% into it, lots more code to go.

    Question: Since we’re grabbing the global

    1
    $wpdb

    on the taxonomy creation, would I have to create three separate function for three taxonomies? Because I just have one function to register each of my tax’s.

    Other that that. Thanks.

  19. Joshua Says:

    Awesome….this tutorial is exactly what I needed……thanks!!!

  20. Paul Menard Says:

    @Joshua: Awesome! thanks.

  21. Daniel Says:

    You are AWESOME! I have been looking for a way to do this for such a long time, and this guide was excellent. Thanks again!

  22. Paul Menard Says:

    @Daniel: Thanks! But be aware there are differences in my original code for 3.0 and newer versions of 3.0.4. Some others have commented on this. So check the comments.

  23. James Beardmore Says:

    Thanks for such an in depth walk through. However I can’t seem to get this to work in 3.0.4, does anyone know what needs to change for 3.0.4?

  24. Paul Menard Says:

    @James Beardmore: I need to revisit the code. I know there are some changes in the upcoming WP 3.1 which bork this code. But this should work in WP 3.0.x

  25. Paul Menard Says:

    @James Beardmore: Actually after a quick test I found my error. I’m surprised anyone was able to get this working. I’ve patched the code example but here is the detail.

    In the add action for the action ‘product_packages_edit_form_fields’ the referenced function was ‘edit_product_packages’. But if you notice the function name itself was singular ‘edit_product_package’. So I updated the name of the function to ‘edit_product_packages’ plural to match add_action call.

    add_action( ‘product_packages_edit_form_fields’, ‘edit_product_packages’, 10, 2);
    function edit_product_package($tag, $taxonomy)

    Hope this helps.

  26. James Beardmore Says:

    Hmmm. I tried this new version completely un-customised with a custom post type of products and I’m still getting no meta for the product packages taxonomy (The .zip download still has “function edit_product_package” as the function btw). I’ll a few things and see what happens, I’ll let you know if I find anything.

  27. Paul Menard Says:

    @James Beardmore: Yeah didn’t update the zip file. The code from the post should be the more up to date. What is not working on your end?

  28. James Beardmore Says:

    All of it. Not to worry, I need to find a way to get this functionality working with 3.1 anyway. Thanks for your help!

  29. Paul Menard Says:

    @James Beardmore: This does work in 3.1. I just worked on a client site doing this. Can you email me your code? I’l see if I can find something.

  30. stein™ Says:

    Thank you for this great tutorial!
    Does this also work on TAGS and what changes need to be made?

  31. Paul Menard Says:

    @stein™:

    Yes this would totally work for adding extra fields to any of the existing WordPress Taxonomies like ‘category’ or ‘post_tag’. The main difference in that logic is you would not need to register a new Taxonomy.

    To hook into the Tags editor. You would replace the call
    add_action( ‘product_packages_edit_form_fields’, ‘edit_product_packages’, 10, 2);

    to one of the WordPress built in hooks
    add_action( ‘edit_tag_form_fields’, ‘your function here’); // Use for post_tag
    add_action( ‘edit_category_form_fields’, ‘your function here’); // Use for category

    When you setup your function which the above action(s) call you will only receive one parameter which is the ‘tag’ or ‘category’. In my code the second parameter for Taxonomy is not use since these are internal WordPress functions.

    The above should get your custom functions displayed on the screen. Now you need to hook into the save term function. For this you need to replace

    add_action( ‘edited_product_packages’, ‘save_product_packages’, 10, 2);

    with one of the following

    add_action( ‘edited_post_tag’, ‘your function here’, 10, 2); // Use for post_tag
    add_action( ‘edited_category’, ‘your function here’, 10, 2); // Use for category

    In your function you still need to support two arguments passed into the function just like for my custom Taxonomy.

    Hope this help.

  32. James Beardmore Says:

    It works in 3.1? Despite not being able to get it running, that’s great to hear. I’ve emailed you my code, thanks for offering to take a look. It’s probably something obvious I’m sure…

  33. stein™ Says:

    Thank you for your prompt response!

    I’ve tried what you suggested (at least i think so), but to no success. It seems the metadata sin’t getting stored.

    Here’s the code i’ve been testing;

    add_action( ‘init’, ‘sh_init’, 0 );

    function sh_init() {

    global $wpdb;

    $wpdb->klinikkmeta = $wpdb->prefix.’klinikkmeta’;
    }

    add_action( ‘edit_tag_form_fields’, ‘edit_tagmeta’);
    function edit_tagmeta($tag)
    {
    $klinikk_adresse = get_metadata($tag->taxonomy, $tag->term_id, ‘klinikk_adresse’, true);

    ?>

    Adresse

    <input type="text" name="klinikk_adresse" id="klinikk_adresse"
    value="”/>
    -

    <?php
    }

    add_action( 'edited_post_tag', 'save_tagmeta', 10, 2);
    function save_tagmeta($term_id, $tt_id)
    {
    //if (!$term_id) return;

    if (isset($_POST['klinikk_adresse']))
    update_metadata($_POST['taxonomy'], $term_id, 'klinikk_adresse',
    $_POST['klinikk_adresse']);
    }

    Any ideas?

  34. Paul Menard Says:

    @stein™:

    In your init function you are setting up a new table ‘klinikkmeta’. This is wrong. Since you are using the build-in Taxonomy ‘post_tag’ this value should be ‘post_tag’. Like the following

    Change this
    $wpdb->klinikkmeta = $wpdb->prefix.’klinikkmeta’;

    to
    $wpdb->post_tagmeta = $wpdb->prefix.’post_tagmeta’;

    Once you have the table definition setup you need to change the name of the column ‘post_id’ to ‘post_tag_id’.

    The rest of the code looks fine.

  35. Lita Dedios Says:

    It’s laborious to search out knowledgeable individuals on this topic, but you sound like you know what you’re talking about! Thanks

  36. Rick Mechanism Says:

    Your RSS feed isn’t working, I tried clicking on it, gives a 404 error.

  37. Mothers Says:

    It’s laborious to find educated people on this matter, but you sound like you already know what you’re speaking about! Thanks

  38. main street fusion bonus Says:

    keep up the great work , I read few content on this web site and I think that your weblog is real interesting and holds sets of great information.

  39. Brad Says:

    I have a problem. The extra fields only show up on the edit screen. They don’t show on Add Categoy for the taxonomy.

  40. Gonzalo Enyeart Says:

    From http://scrapeboss.com

  41. Charles Digilio Says:

    I wanted to jot down a simple word so as to thank you for some of the magnificent items you are sharing on this site. My extensive internet look up has now been recognized with excellent concept to talk about with my family. I ‘d point out that we website visitors are definitely endowed to live in a remarkable place with many special people with helpful secrets. I feel extremely fortunate to have used the web page and look forward to really more enjoyable times reading here. Thank you again for all the details.

  42. Andres Hermosilla Says:

    Awesome article! Helped tons! For the DB I just used
    global $wpdb;
    $table_name = $wpdb->prefix . “locationmeta”;
    require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);

    if($wpdb->get_var(“show tables like ‘$table_name’”) != $table_name) {

    $sql = “CREATE TABLE $wpdb->dbname.$table_name (
    meta_id BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    location_id BIGINT( 20 ) NOT NULL DEFAULT ’0′,
    meta_key VARCHAR( 255 ) NULL ,
    meta_value LONGTEXT NULL DEFAULT NULL
    ) ENGINE = MYISAM ;
    “;
    }

    dbDelta($sql);
    $results = $wpdb->query( $insert );

  43. bubble pop game Says:

    My spouse and I absolutely love your blog and find the majority of your post’s to be exactly what I’m looking for. Does one offer guest writers to write content for yourself? I wouldn’t mind publishing a post or elaborating on some of the subjects you write about here. Again, awesome blog!

  44. hp mini 210 Says:

    Tired of getting low amounts of useless traffic for your website? Well i want to inform you of a new underground tactic that makes me personally $900 each day on 100% AUTOPILOT. I could be here all day and going into detail but why dont you simply check their site out? There is really a excellent video that explains everything. So if your seriously interested in making quick hard cash this is the site for you. Auto Traffic Avalanche

  45. iframe Says:

    Good. Very good

  46. Dan Imbrogno Says:

    Great article! I’d recommend to other readers to read this entire article first before you try to follow along. I kept skipping steps thinking I knew what I was doing, only to realize my mistakes were covered further on in the article.

  47. Zakir Says:

    I have a problem. The extra fields only show up on the edit screen. They don’t show on Add Categoy for the taxonomy. My version of wordpress is 3.2.1.

    any clues?

  48. Zakir Says:

    Sorted out.

  49. Damian Says:

    Thanks for all the info!! It helped me a lot.
    You can also save all data into the options table instead of creating new tables in the database.
    I did the following for my “galleries” taxonomie

    add_action( ‘edited_galleries’, ‘save_extra_category_fileds’, 10, 2);
    // save extra category extra fields callback function
    function save_extra_category_fileds( $term_id, $tt_id ) {
    if ( isset( $_POST['Cat_meta'] ) ) {
    $t_id = $term_id;
    $cat_meta = get_option( “category_$t_id”);
    $cat_keys = array_keys($_POST['Cat_meta']);
    foreach ($cat_keys as $key){
    if (isset($_POST['Cat_meta'][$key])){
    $cat_meta[$key] = $_POST['Cat_meta'][$key];
    }
    }
    //save the option array
    update_option( “category_$t_id”, $cat_meta );
    }
    }

    //add extra fields to category edit form hook
    add_action ( ‘galleries_edit_form_fields’, ‘extra_category_fields’, 10, 2);
    //add extra fields to category edit form callback function
    function extra_category_fields( $tag , $taxonomy) { //check for existing featured ID
    $t_id = $tag->term_id;
    $cat_meta = get_option( “category_$t_id”);
    ?>

    <input type="text" name="Cat_meta[img]" id="Cat_meta[img]" size="3" style="width:60%;" value="”>

    <?php
    }

  50. 2046 Says:

    Because I wanted to make couple new meta fields for taxonomies and was bored to manually duplicate tables. I made this sql command:

    CREATE TABLE IF NOT EXISTS `wp_METANAMEmeta` (
    `meta_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
    `METANAME_id` int(20) unsigned NOT NULL,
    `meta_key` varchar(255) DEFAULT NULL,
    `meta_value` longtext,
    PRIMARY KEY (`meta_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

    Change the “METANAME” according to your meta name. Plus be aware that it creates the table in UTF-8 decoding!

  51. Empire Says:

    ?”Its always good to learn tips like you share for blog posting. As I just started posting comments for blog and facing problem of lots of rejections. I think your suggestion would be helpful for me. I will let you know if its work for me too.”

  52. Dorathy Stiggers Says:

    This is a excellent web site, will you be interested in doing an interview about just how you developed it? If so e-mail me!

  53. » Extending Meta Features in WordPress | Michael Lipson Says:

    [...] more information about the taxonomies.  After a quick Google search, I found this article on Code Hooligans showing how to add that through meta boxes.  For being authored in 2010, it seems strange that it [...]

  54. WordPress Snippets Collection - MINIMALITE Says:

    [...] Developers And Consultants Learn the Art of Writing Search Engine Friendly URLs from Matt Cutts Custom Meta for new Taxonomies in WordPress 3.0 « CodeHooligans Tweet !function(d,s,id){var [...]