Black Friday Sale is now Live

Dynamic tag for term key

  • Posted 2 months ago

Hello,

I’m trying to get the taxonomy key (like “category”, “product_cat”, etc.) when using term dynamic tags in Voxel, similar to how we can get the post type with @post(:post_type.key).

I want to use the same template on all product term templates and keep all my filters but filter all of them by default value. For example, in the brands filter, my idea was to use a condition “if term type is ‘brand’ then @post(id)”.

I was thinking term-data-group.php could use something like:

‘taxonomy’ => Tag::Object(‘Taxonomy’)->properties( function() {
return [
‘key’ => Tag::String(‘Key’)->render( function() {
return $this->term->taxonomy ? $this->term->taxonomy->get_key() : ”;
} ),
];
} ),

In the aliases() method: ‘:taxonomy’ => ‘taxonomy’,

So we could use @term(:taxonomy.key) – Get taxonomy key

QUESTIONS

1. Am I missing an existing way to get the taxonomy key/type from term dynamic tags?

2. If not, could this be added to core? It seems like a natural parallel to @post(:post_type)

3. Is there a way to extend term properties without modifying core files? (No hooks/filters seem available) I really prefer to use a code snippet in wpcode.

Thank you