Insert this code into your WordPress theme’s functions.php:
function tqt_vtdevs_get_product_tags(){
$args = array(
'taxonomy' => 'product_tag',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
);
$all_product_tag = array();
// $cus_product_tag = array();
$the_query = new WP_Term_Query($args);
$all_terms = $the_query->get_terms();
if ( empty( $all_terms ) || is_wp_error( $all_terms ) ) {
echo '$the_query->get_terms() is error.';
exit;
}
foreach($the_query->get_terms() as $term) {
$all_product_tag[] = $term;
// if ($term->slug == 'special-edition-product') $cus_product_tag[] = $term;
}
print_r($all_product_tag);
// print_r($cus_product_tag);
exit;
}
if (!empty($_GET['gtags'])) {
tqt_vtdevs_get_product_tags();
exit;
}
Output:
Array
(
[0] => WP_Term Object
(
[term_id] => 3451
[name] => Special Edition
[slug] => special-edition
[term_group] => 0
[term_taxonomy_id] => 3451
[taxonomy] => product_tag
[description] =>
[parent] => 0
[count] => 5
[filter] => raw
)
…
)

Bài viết cùng chuyên mục, chủ đề