WP query taxonomy input differs to output?

A curious journey of a “cat“ Let’s assume we have the following category hierarchy: where the relevant rows from the wp_term_taxonomy table are: We want to query all posts in the animals category where the id is 65: $query = new WP_Query( array( ‘cat’ => 65 ) ); and try to understand why the resulting … Read more

Could not insert term into the database

OK. There where multiple issues here; wp_terms, wp_termmeta and wp_term_taxonomy all had their ID’s set not to AUTO_INCREMENT. Changing these and removing the 0 values from each table seems to have resolved this – very odd though. Big thanks to @N00b for helping!

Control term order on a per-post basis

I’m not sure if I understand exactly what your trying to accomplish but I’ve outlined a way for you to sort the order of terms associated with the current post. Html for the term order metabox: echo ‘<ul id=”the-terms”>’ $terms = get_the_terms( $post->ID, $taxonomy ); foreach ( $terms as $term ) { echo ‘<li class=”item” … Read more

Separate Media Library for each user

Built in features The Media Library has major updates with the upcoming version. You can see the changes in the slides by Daryl Koopersmith here. You can read the announcement and discussion on “Make”. Your request for “tags/categories” is already built into 3.5. Note The difference between themes and plugins is pretty easy: Display vs. … Read more

Custom Taxonomy as Dropdown in admin

This suppose you have a custom post type “sponsors” and a custom taxonomy “types”… function custom_meta_box() { remove_meta_box( ‘tagsdiv-types’, ‘sponsors’, ‘side’ ); add_meta_box( ‘tagsdiv-types’, ‘Types’, ‘types_meta_box’, ‘sponsors’, ‘side’ ); } add_action(‘add_meta_boxes’, ‘custom_meta_box’); /* Prints the taxonomy box content */ function types_meta_box($post) { $tax_name=”types”; $taxonomy = get_taxonomy($tax_name); ?> <div class=”tagsdiv” id=”<?php echo $tax_name; ?>”> <div class=”jaxtag”> … Read more

Automatically Assign Parent Terms When A Child Term is Selected

Hooking into save_post action. add_action(‘save_post’, ‘assign_parent_terms’, 10, 2); function assign_parent_terms($post_id, $post){ if($post->post_type != ‘product’) return $post_id; // get all assigned terms $terms = wp_get_post_terms($post_id, ‘product_cat’ ); foreach($terms as $term){ while($term->parent != 0 && !has_term( $term->parent, ‘product_cat’, $post )){ // move upward until we get to 0 level terms wp_set_post_terms($post_id, array($term->parent), ‘product_cat’, true); $term = get_term($term->parent, … Read more

How to display custom taxonomies in posts?

The easiest way to list terms of custom taxonomy and display them would be to use <?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> For example in the loop, my custom taxonomy is ‘jobs’ list as li <ul><?php echo get_the_term_list( $post->ID, ‘jobs’, ‘<li class=”jobs_item”>’, ‘, ‘, ‘</li>’ ) ?></ul>