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

What is the “meta” key in WP_Term Object?

Looking at the source, that meta property isn’t a standard property in the WP_Term object. However, a plugin/theme can add custom properties to the object using the get_term or get_{taxonomy} filter: add_filter( ‘get_term’, function( $term ){ $term->meta = get_term_meta( $term->term_id ); // all metadata return $term; } );

How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more

How to get the $meta_type given the $object_id

Given the $object_id (and a WP_Term object), how does one go about determining the $meta_type to be passed to update_metadata()? Unfortunately, that is not possible because each object has its own table and therefore the same ID (1, 2, 3, etc.) could refer to a post, comment, term, etc. So that’s why we have different … Read more

techhipbettruvabetnorabahisbahis forumueduseduseduedusedueduedusedusedusedus