Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
Adding Custom Field to Taxonomy Input :Panel

I created a custom post type with a taxonomy associated. When I add new item for my taxonomy, I get name, slug and description. I want a new field in there, because I also need to add a image in my taxonomy.php file

This is what I use to get the name and description:

<?php
if(isset($wp_taxonomies)) {
    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    if($term) {
        echo '<h1>'.$term->name.'</h1>';
        ?> <img class="alignright" alt="<? echo $tax_term->name; ?>" src="<? echo $term->description; ?>" /> <?php
    }
}
?>

Can you tell my how can I hook a new textarea in my custom taxonomy and get-it in my taxonomy page?

Thank you!

share|improve this question

marked as duplicate by toscho Jul 17 '12 at 23:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

You should be able to do something like this:

add_action("manage_posts_custom_column", "my_custom_columns");
add_filter("manage_edit-[POSTTYPE]_columns", "my_new_columns");

function my_new_columns($columns)
{
    $columns = array(
        "image" => "Image"
    );
    return $columns;
}

function my_custom_columns($column)
{
    global $post;
    if ("ID" == $column) echo $post->ID;
    elseif ("image" == $column) echo 'default_value';
}

Then you should be able to use $tax_term->image to show it.

This is untested but see this article for more info. Also look into the hooks manage_edit-post_type_columns and manage_posts_custom_column You may also want to edit the code to show an image upload field instead of a text field but it at least gets you started.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.