Add custom post type taxonomy tag to article class

Ah, solved it! <aside class=”work_item <?php $posttags = get_the_terms($post->ID, ‘type’); if ($posttags) { foreach($posttags as $tag) { echo str_replace(‘-‘,’_’,$tag->slug . ‘ ‘); } } ?>” data-type=”<?php $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { echo str_replace(‘-‘,’_’,$tag->slug . ‘ ‘); } } ?>”> had to use the get_the_terms() function

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

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

Custom Post Type Taxonomy Term Order by Title

After about 100 different tries, I got it to work. Not sure if there is a better way, but it works. $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName ); $args = array( ‘post_type’ => ‘clients’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’=>array( array( … Read more

Custom Taxonomy List with Children

Your code works perfectly in a custom taxonomy template file. CASE 1 You’re trying to use this code in a single page or something else and it doesn’t work because the object returned from get_queried_object() isn’t a taxonomy. The function get_queried_object() return the currently-queried object. So, if you need a Taxonomy Object you have to … Read more

Using in ‘category_name’ in ‘$query->set();’?

I am unable to duplicate the problem, but the Notice references this line: add_screen_option( ‘per_page’, array( ‘label’ => $title, ‘default’ => 20, ‘option’ => ‘edit_’ . $post_type . ‘_per_page’ ) ); And that makes me think that you should be passing a post type in your GET string. http://wp.dev/wp-admin/edit.php?post_type=post&category_name=intl Just a guess as I can’t … Read more

Get terms for a specfic post from multiple taxonomies in custom post type

You kind of not telling what the problem is, like debug, error message you get. There is most likely something wrong with how you wrote that, I’m not willing to go trough this right now. But generally you should make this cleaner and separate parts for an better structure, regarding the taxonomy name as id … Read more

Trying to use wp_set_object_terms while supplying an array for both term id, and texonomies

what i ended up doing: foreach($this->parents as $parent){ $taxonomies[] = $parent[‘app_name’]; } wp_delete_object_term_relationships( (int)$parent[‘item_id’], array_unique( $taxonomies ) ); foreach($this->parents as $parent){ $cat_id = (int)$parent[‘item_id’]; $taxonomy = $parent[‘app_name’]; wp_set_object_terms( (int)$parent[‘item_id’], $cat_id,$taxonomy, true); } This solution is a little longer but it worked and i couldn’t spend more time searching the problem. Thanks