Order taxonomy terms by the frequency of use in the last 30 days

First thing’s first — You’ll have to add that table. The way you do that if you were writing this in a plugin is as follows: function customtaxorder_init() { global $wpdb; $init_query = $wpdb->query(“SHOW COLUMNS FROM $wpdb->terms LIKE ‘term_order'”); if ($init_query == 0) { $wpdb->query(“ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT ‘0’”); … Read more

Why is taxonmy-[taxonomyname].php not working?

I think this is because you use a reserved name: http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms Try changing in to something else like: register_taxonomy(‘portfolio_category’, ‘portfolio’, array(‘hierarchical’ => false, ‘label’ => ‘Category’,’query_var’ => true, ‘rewrite’ => true));

Description of a sub-taxonomy

Term description works only with term id and the taxonomy name, so if you want to get the sub term’s description, you should first get all the children of a term(and their children, if its another level deep) and loop over their ids with a single term_description call per id. <?php $my_taxonomy = ‘institute’; $terms … Read more

Implode Taxonomy to hide parents?

You can check if the resulting term has any children before adding it to the array: $terms = get_the_terms($wp_query->post->ID, ‘propertytype’); $props = array(); foreach ($terms as $term) { $hasChildrenTest = get_term_children($term->ID, ‘propertyType’); if ($term->parent) { if (empty($hasChildrenTest) && !is_wp_error($hasChildrenTest)) { $props[] = $term->name; } } echo implode(‘, ‘, $props); ps: the if($term->parent) test might become … Read more

Why does my taxonomy code display the first alphabetical term?

With wp_get_object_terms() you’re able to manipulate the sorting. Make sure you tweak the sorting to what you want. Try something more or less like this (Updated: 5/17/2012 — 8:15AM): $taxonomyName=”producttype”; $terms = wp_get_object_terms($wp_query->post->ID, $taxonomyName, array(‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘fields’ => ‘all’)); if(!empty($terms)){ if(!is_wp_error($terms)){ for($i = 0; $i < count($terms); $i++){ if($terms[$i]->parent != 0){ … Read more

Passing values by form to create a query

It all depends on how you’re trying to do it. When it comes to filtering results, i usually setup the form to use $_GET and filter the results when the page loads again: if (isset($_GET[‘term’])) { $term = $_GET[‘term’]; } else { $term = ‘defaultTerm’; } if (isset($_GET[‘childterm’])) { $childterm = $_GET[‘childterm’]; } else { … Read more

Show min and max taxonomy values

Not sure but try this: function get_years ($taxonomies, $args){ $output = array(); $hlterms = get_terms($taxonomies, $args); foreach($hlterms as $term){ $term_taxonomy = $term->year; array_push($output, $term->name); } return $output; } $taxonomies = array (‘year’); $args = array (‘hide_empty’=>true); $year = get_years($taxonomies, $args); echo min($year);

Echo used hierarchical taxonomies parent name

Try this: <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $parent = get_term($term->parent, get_query_var(‘taxonomy’) ); echo $parent->name; ?> You have to get the current term slug and then use get_term by the slug and then echo the name.