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

setting taxonomy term to bulk posts using ids

I hope I understand this correctly. You can simply just add your post ID’s in an array and then use a foreach loop to loop through the ID’s and checking whether or not they have the term to assign or not, and if not, assign the term to the post $post_ids = [4522, 4524, 4526, … Read more

get_terms orderby numeric

You can use usort to sort the object $children. The function to sort after you got the $children object can be like this: usort( $children, function($a, $b) { $ai = filter_var($a->name, FILTER_SANITIZE_NUMBER_INT); $bi = filter_var($b->name, FILTER_SANITIZE_NUMBER_INT); if ($ai == $bi) { return 0; } return ($ai < $bi) ? -1 : 1; });

Invalid argument supplied for foreach() in search.php

Because get_the_terms will not always return an array; it will be false if the post has no terms, or a WP_Error if the taxonomy does not exist – always sanity check the result before looping: $terms_slugs = array(); $terms = get_the_terms( $post->id, ‘type’, /* Note: get_the_terms does not take a 3rd argument ==> */ array( … Read more