S
S
sergeyviktorovich2021-08-01 15:03:37
WordPress
sergeyviktorovich, 2021-08-01 15:03:37

How to get the name of a product attribute term by slug?

It didn't work out that way:

global $product;
 $term = get_term_by( 'slug', 'Ink_black', 'product' );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-08-02
@artzolin

Because 'product' is a post type, not a term. Try using 'product_tag'

$term = get_term_by( 'slug', 'ink_black', 'product_tag' );
var_dump( $term->name );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question