get_attached_media() on author page not working

I assume that you have a simple misunderstanding of what this function actually does and what it should be used for: get_attached_media() simply fetches all child posts for a given posts: if ( ! $post = get_post( $post ) ) return array(); $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => $type, ‘posts_per_page’ … Read more

Preserve term order per post in a non-hierarchical taxonomy

I encountered a similar issue and this is how I solved it. Note that I put in Fruits as the taxonomy name based on your example. It’s important that this name matches the taxonomy name exactly. Often taxonomy names are singular, i.e. fruit function wp4382_filter_terms_order( $orderby, $query_vars, $taxonomies ) { if ( ! empty( $query_vars[‘object_ids’] … Read more

Wrapping result of the_terms in a span with a class of the term name

Generally speaking in the WordPress world, functions prefixed with the_ will output results immediately. Functions prefixed with get_ will return the results without outputting them. The function get_the_terms() can be used to achieve the desired results. Here’s a complete function that’s essentially a wrapper for get_the_terms() with a little bit of extra formatting: /** * … Read more

Query/list all terms and their custom post count

If the taxonomies in question are used ONLY in the post_type in question, then the following simple function will do what you need: function count_term_use ($post_type) { $args = array ( ‘taxonomy’ => get_object_taxonomies ($post_type, ‘names’), ) ; foreach (get_terms ($args) as $term) { echo “$term->name – $term->count\n” ; } return ; } However, if … Read more

How I can get custom field’s current value?

The author of plugin help me with that. Thanks all. global $post; $product_colors = get_the_terms( $post, ‘product_color’ ); $saved_colors = get_option( ‘nm_taxonomy_colors’ ); if(isset($product_colors) && is_array($product_colors)){ foreach($product_colors as $color){ $term_id = $color->term_id; $hex_code = $saved_colors[$term_id]; echo $hex_code . ‘<br />’; } }

get_term_link() returns incorrect url

WordPress allows for customization of the default URL rewrite behavior (/slug/term) with a rewrite arguments array passed to the register_taxonomy() function. By defining values for the slug or hierarchical keys in this array, the default URL structure can be altered to suit your needs. It may also be altered such that unexpected results are returned. … Read more