get_terms_args ordering by meta key not working

After a lot of searching and tests… Finally I’ve found a solution. Instead using get_terms_args filter, I’ve changed to parse_term_query action. My resulting code looks this way now: add_action(“parse_term_query”, “MyTheme_ParseTermQuery”, PHP_INT_MAX, 1); function MyTheme_ParseTermQuery(&$query) { $taxonomy = $query->query_vars[‘taxonomy’][0]; if($taxonomy == “edition”){ $query->query_vars[‘order’] = “ASC”; $query->query_vars[‘orderby’] = “meta_value_num”; $query->query_vars[‘meta_query’] = [[ ‘key’ => “_edition”, ‘type’ => … Read more

wp_set_object_terms setting only first id from array

Turns out someone had the same problem and answered their own problem here. wp_set_object_terms not accepting variable array Here’s my working solution for my problem: $image_category = array_map(‘intval’, $_POST[‘image_category’]); wp_set_object_terms($product->get_id(), $image_category, ‘product_cat’); Hope this helps someone else. Thanks for reading.

Customizing the wordpress tag-cloud output

This is how the links are created in wp_generate_tag_cloud (wp-includes/category-template.php) foreach ( $tags as $key => $tag ) { $count = $counts[ $key ]; $real_count = $real_counts[ $key ]; $tag_link = ‘#’ != $tag->link ? esc_url( $tag->link ) : ‘#’; $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; $tag_name = $tags[ $key … Read more

wp_set_object_terms timing out?

Dealing with terms is known to be very heavy operation. The common tweak recommended is to use wp_defer_term_counting() to temporarily disable updating of terms count (which is stored persistently in database and so must be updated when you change terms).