WP_insert_term how to insert multiple values as taxonomny term?

I would build the input fields for terms as array of inputs. Like this (note the [] inthe name attribute: <input name=”input_name[]” type=”text” value=””> <input name=”input_name[]” type=”text” value=””> <input name=”input_name[]” type=”text” value=””> Then, in PHP: //Now $_POST[‘input_name’]; is an array //get the array and sanitize it $input_terms = array_map( ‘sanitize_text_field’, $_POST[‘input_name’] ); //Set the array … Read more

Create and move terms for taxonomies

wp_update_term() doesn’t changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, ‘category’, array( ‘name’ => ‘Uncategorized Renamed’, ‘slug’ => ‘uncategorized-renamed’ ) ); if ( ! is_wp_error( $update ) ) { echo ‘Success!’; } This code finds the category which ID is 1, then updates it to the name … Read more

Taxonomy query for children of parents

Use get_queried_object() to get the current queried term on a category page: $this_term = get_queried_object(); $args = array( ‘parent’ => $this_term->term_id, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ); $child_terms = get_terms( $this_term->taxonomy, $args ); echo ‘<ul>’; foreach ($child_terms as $term) { echo ‘<li><h3><a href=”‘ . get_term_link( $term->name, $this_term->taxonomy ) . ‘”>’ . $term->name . ‘</h3></a></li>’; … Read more

Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy

Something like this should help: <?php $post_type=”animals”; $tax = ‘vertebrate’; $tax_terms = get_terms($tax); if ( $tax_terms ) { foreach ($tax_terms as $tax_term) { $args = array( ‘post_type’ => $post_type, “$tax” => $tax_term->slug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’ => 1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); // $my_query = null; <- REMOVE THIS, … Read more