wp_set_post_terms is assigning only the last of several terms to a post

You need send a fourth argument to the function: wp_set_post_terms($post_id, $actor_term_id, ‘actor’, true); Each time the function executes, you’re replacing any existing terms. The fourth argument specifies that you wish to append them. https://codex.wordpress.org/Function_Reference/wp_set_post_terms

Display custom taxonomy attached to the post on post single page

You can get every Taxonomy by $categories = get_the_terms( get_the_id(), $taxonomy-slug ); if ( is_array( $categories ) ) { foreach ( $categories as $category ) { echo ‘<a href=”‘ . get_term_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a> ‘; … Read more

Get post by term from custom taxonomy in another blog on the network?

I found a small hack to filter by taxonomy without create the taxonomy in the child theme. In the core exists the function “taxonomy_exists“: function taxonomy_exists( $taxonomy ) { global $wp_taxonomies; return isset( $wp_taxonomies[$taxonomy] ); } And is this function who hive “false” because the taxonomy don’t exists in your child theme. If this function … Read more

get_terms function not returning anything

get_terms just returns an array of terms, it doesn’t generate output. You have to do something with that array to see the results- $categories = get_terms( “category” ); echo “<ul>”; foreach ( $categories as $category ) { echo “<li>” . $category->name . “</li>”; } echo “</ul>”; See the other examples on the Codex page.

How to add terms (without deleting others)

The fourth parameter to wp_set_object_terms() is an “append” argument. $append (bool) (required) If true, tags will be appended to the object. If false, tags will replace existing tags Default: False http://codex.wordpress.org/Function_Reference/wp_set_object_terms Your code should work if you pass true as that fourth argument. wp_set_object_terms( $post->ID, explode( ‘,’, $_POST[‘postTags’] ), ‘product_tag’, true );

Get Custom Taxonomy Terms by Date

This is the working code: // latest edition $taxonomies = array( ‘jjm_editions’ ); $args = array( ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘hide_empty’ => false, ‘number’ => ‘1’ ); $terms = get_terms($taxonomies, $args); foreach ( $terms as $term ) { $term_link = get_term_link( $term ); if ( is_wp_error( $term_link ) ) { continue; } echo … Read more

How to get a post’s associated taxonomies and terms in wp api v2

Ok, I just stumbled upon the answer buried deep in the github issues page: https://github.com/WP-API/WP-API/issues/1403 The answer is: the reason is that the terms / meta etc are different objects, and in typical REST design going a GET on a single resource, will give you that resource, not that resource and a bunch of other … Read more