get_post_terms not working as expected

I misunderstood what you were trying to do before. I thought you wanted to list the terms associated with one particular post – the one you are on. Whoops! Try this instead: $terms = get_terms(‘fruit_category’); if(!empty($terms)){ echo “<ul>”; foreach ( $terms as $term ) { echo ‘<li><a href=”‘.get_term_link($term->slug, ‘fruit_categories’).'”>’. $term->name . “</a></li>”; } echo “</ul>”; … Read more

How to show term-specific post list, without posts associated with child terms?

As @Milo’s pointer said, this: Sadly, is normal WordPress behaviour. Can be suppressed using parse_tax_query and include_children set at 0… The code found in the answer at https://wordpress.stackexchange.com/a/202773/39300 Works for me… function taxonomy_archive_exclude_children($query){ $taxonomy_slugs = [‘product_category’, ‘application_category’]; if($query->is_main_query() && is_tax($taxonomy_slugs)){ foreach($query->tax_query->queries as &$tax_query_item){ if(empty($taxonomy_slugs) || in_array($tax_query_item[‘taxonomy’], $taxonomy_slugs)){ $tax_query_item[‘include_children’] = 0; } } } } add_action(‘parse_tax_query’, … Read more

Get parent and first child taxonomy terms?

There is unfortunately no way that you are going to do this in one or two queries. It seems that there are a misunderstanding or misconception about database queries. The most important aspect to keep in mind when you are running database queries is the amount of database queries vs. the time these queries will … Read more

Add Thumbnail to wp_list_categories()

The original question uses get_tax_meta() which does not exist in WordPress core but may be a custom function created by the asker. In this case we could switch it out just as well with get_term_meta(). You could try this: class List_Category_Images extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), $id … Read more

How to have “the most used tags” taxonomy always expanded?

There does not appear to be any way to hook into that from inside PHP http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/meta-boxes.php#L300 So JavaScript will probably best suit as a quick and easy solution. add_action( ‘admin_footer-post-new.php’, ‘wpse_45149_inject_script’ ); function wpse_45149_inject_script() { $expand_for = array( ‘post_tag’ ); // add taxonomy names here // build a nice jQuery query foreach ( $expand_for as … Read more

Set default (auto) slug prefix for Tags

You can use the created_term or the created_{taxonomy} hooks which are fired just after a taxonomy term is created (the second only if it matches the taxonomy). The following will only alter terms in the taxonomy ‘my-taxonomy’. (I believe for the default tags, taxonomy should be ‘post_tag’). add_action(‘created_term’, ‘my_add_prefix_to_term’, 10, 3); function my_add_prefix_to_term( $term_id,$tt_id,$taxonomy ) … Read more