0

i am trying to add an image field to the wp_term table in the database, I'll call it icon.

I want that filed to contain a URL to an image that will be the thumb for the category. I have already added the field to the DB and I have also inserted it into the code in the admin panel :

<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="icon"><?php _ex(' Icon', 'Taxonomy Icon'); ?></label></th>
    <td><input name="icon" id="icon" type="text" value="<?php if ( isset( $tag->icon ) ) echo esc_attr($tag->icon); ?>" size="40" />
    <p class="description"><?php _e('The &#8220;icon&#8221; is the URL to the category icon. if it is an uploaded image it will be http://'.$_SERVER['SERVER_NAME'].'/wp-content/uploads/{your_file.name}.'); ?></p></td>
</tr>
<?php endif; // is_taxonomy_hierarchical() ?>

the code shows the content from the database if it is preset but doesnt update it.

what/where do i need to add so that it will also update the DB icon field?

thank you.

1 Answer 1

0

I had some trouble saving custom taxonomy fields, which I resolved in this WPSE post. I was using the options table to save my data, but the same solutions may apply for you too. Firing callbacks attached to create_{taxonomy} and edited_{taxonomy} were part of the solution.

3
  • thank you very much for your answer but i found a great little plugin that lets me add all kinds of metadata to my categories link
    – Dvir Levy
    Commented Mar 26, 2012 at 23:30
  • haha funny there solution is what i used, thanks for it :)
    – Dvir Levy
    Commented Mar 26, 2012 at 23:32
  • Cheers, glad you go it worked out. Commented Mar 26, 2012 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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