Is there a way to change select-list for new custom taxonomy?

If someone else stumble upon this kind of question, here’s my solution to it: (without having to mangage any metaboxes etc) add_action(‘categorycourses_add_form_fields’,’categorycourses_edit_form_fields’); add_action(‘categorycourses_edit_form_fields’,’categorycourses_edit_form_fields’); //Function only showing parent categories when editing or adding new category-courses function categorycourses_edit_form_fields() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { var level = 1; //Go down in hierarchy from level1 and remove … Read more

Adding Child Terms Programatically – No Warning but No dice either

It doesn’t work because you use wp_insert_term function incorrectly. Please read the codex manual page carefully and you will see that the second argument is not parent slug, but your custom taxonomy. So your function should look like this: create_taxonomy_record($args) { $parent_term = 0; if (!empty($args[2]) && ($parent_term = term_exists($args[2], $args[1])) { $parent_term = $parent_term[‘term_id’]; … Read more

Add term for custom taxonomy from front end

Your code doesn’t assign the terms to the post. You can do this with wp_set_post_terms() which does: Set terms for a post. Simplified usage example: $pet_cat_ term = $_POST[‘pet_category’]; wp_set_post_terms( $post_id, $pet_cat_ term, ‘pet-category’ ); Additional note: use the id as value for your term select(s), to prevent problems, i.e. because for hierarchical terms you … Read more

List terms of custom taxonomy if matches other taxonomy

Your approach isn’t bad, but instead of echoing all of these out, you should store them in an array, then use array_unique to remove duplicate entries before displaying. <?php $array_out = array(); while ($the_query->have_posts()) : $the_query->the_post(); ?> $terms = get_the_terms( $post->ID, ‘city’); foreach($terms as $term){ $term_link = get_term_link($term, ‘city’); $array_out[] = ‘<a href=”‘.$term_link.'”>’.$term->name.'</a>’; } endwhile; … Read more

Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT

Note that category and post_tag are both taxonomies, and that they are taxonomies that, by default, are only supported by the post post type. You have created a custom post type, and have registered support for a custom taxonomy for it: books_taxonomy. Thus, it makes perfect sense that a query for posts with the books … Read more

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more