Do I have to set parent when set post term?

When you create a term for a hierarchical taxonomy, if you don’t specify a parent, its parent ID is set to 0. In other words, it becomes a parent term. Edited with regards to comments: Add specifically each term you wish to add to the post (parent terms aren’t automatically added if their children are). … Read more

List custom taxonomy terms from custom field

The problem you are facing is that get_the_terms() returns an array (or false or a WP_Error-Object), not a string. So, assuming that you have multiple terms for images, you could use a code like this: if( $labels && !is_wp_error( $labels ) ) { foreach( $labels as $label ) { $labelarray[] = $label->name; } $labelstring = … Read more

get_the_terms return only last term

Instead of get_the_terms try using get_terms and set the hierarchal argument to true. Also make sure you show empty so you are not hiding your empty categories. Try something like this: $args = array( ‘hide_empty’ => false, ‘hierarchical’ => true ); $terms = get_terms(‘portfolio_pt’, $args); foreach($terms as $term) echo $term->name;

Exclude Taxonomy Terms from Template Via Back End?

You might be able to accomplish this using Advanced Custom Fields: http://www.advancedcustomfields.com/resources/taxonomy/ Field groups, like the taxonomy field, can be assigned to templates. Editing the taxonomy archive page, the user would see checkboxes (or radio buttons, or a select menu) for the taxonomy terms. In the corresponding “taxonomy archive” template (from link above)… <?php $terms … Read more

Insert form checkbox at bottom of taxonomy edit term page

My bad – the mark up for the edit page is different than add. Used this instead add_action(‘provider_edit_form_fields’, array($this, ‘category_metabox_edit’), 10, 1); // add image field in edit form function category_metabox_edit($tag) { $term_val = get_term_meta($tag->term_id, ‘show_on_provider’, true); $term_val == 1 ? $checked = ‘checked’ : $checked = ”; echo ‘<tr class=”form-field”> <th scope=”row” valign=”top”><label for=”show_on_provider”>’ … Read more

Display assigned terms with link

Keep in mind that the return value of get_the_terms() can be of the type of array|WP_Error Your snippet should check if you get the correct type returned $terms = get_the_terms( 0, ‘product_tag’ ); if ( ! is_wp_error( $terms ) AND is_array( $terms ) AND ! empty( $terms ) ) { foreach( $terms as $term ) … Read more