I'm trying to create a front end taxonomy and term interface.
I currently have:
<form id="updatetax" method="post">
<input name="term_name" type="text" value="">
<select name="tax_selection">
<?php $taxonomies = get_object_taxonomies( 'cpt_taxonomy', 'objects' ); ?>
<option value="">Select an option</option>
<?php
foreach( $taxonomies as $taxonomy ) {
echo '<option value="' . $taxonomy->name . '">' . $taxonomy->label . '</option>';
}
?>
</select>
<!-- I have a hidden input with the term ID and the current taxonomy if updating -->
<input name="termID" value="<?php echo $_GET['termID']; ?>">
<input name="currentTax" value="<?php echo $_GET['currentTax']; ?>">
</form>
Then in the submission, I get the fields and try to update the term:
<?php
$term_args = array(
'name' => $_POST['term_name'],
'taxonomy' => $_POST['tax_selection'],
'term_id' => $_POST['termID']
);
wp_update_term( $_POST['termID'], $_POST['currentTax'], $term_args );
?>
In the codex it seemed that's all was needed to do to update the term. However, though I can get the title to update, I cannot seem to get the taxonomy to change and update.
I was wondering what I am doing wrong. My end goal to it be able to move/update the terms between taxonomies, add new ones from the form above (by selecting the taxonomy in the select field), and add custom term meta.