Calling wp_update_term cleares image
-
Hi all,
I’ve created an import procedure on WordPress to update custom taxonomies by CSV.
I use
wp_update_term
when I need to change taxonomy’s name. Doing so, images previously set are cleared.I’ve fixed with this workaround code:
$image = get_term_meta( $term_id, 'image', true ); wp_update_term( $term_id, 'categoria', $update_data ); if( !empty( $image ) ) update_term_meta( $term_id, 'image', $image );
After some investigation, I think the problem is when you hook into
term_edit
action you should check that you’re interm.php
context or you can simply check that$_POST['term-image']
is set (not just empty).Thanks
D.
- The topic ‘Calling wp_update_term cleares image’ is closed to new replies.