Last active
March 21, 2017 20:04
-
-
Save marcosnakamine/099f6b8c515a55df16f27ffba19d9f0e to your computer and use it in GitHub Desktop.
WooCommerce - Get product categories, image and permalink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cat = get_categories( array( | |
'taxonomy' => 'product_cat' | |
) ); | |
foreach( $cat as $key => $value ){ | |
echo $value->name; | |
echo wp_get_attachment_url( get_term_meta( $value->term_id, 'thumbnail_id', true ) ); | |
echo get_term_link( $value->term_id, 'product_cat' ); | |
var_dump( $value ); | |
} | |
/* | |
object(WP_Term)#8758 (16) { | |
["term_id"]=> | |
int(33) | |
["name"]=> | |
string(20) "Caçarolas e panelas" | |
["slug"]=> | |
string(19) "cacarolas-e-panelas" | |
["term_group"]=> | |
int(0) | |
["term_taxonomy_id"]=> | |
int(33) | |
["taxonomy"]=> | |
string(11) "product_cat" | |
["description"]=> | |
string(0) "" | |
["parent"]=> | |
int(0) | |
["count"]=> | |
int(12) | |
["filter"]=> | |
string(3) "raw" | |
["cat_ID"]=> | |
int(33) | |
["category_count"]=> | |
int(12) | |
["category_description"]=> | |
string(0) "" | |
["cat_name"]=> | |
string(20) "Caçarolas e panelas" | |
["category_nicename"]=> | |
string(19) "cacarolas-e-panelas" | |
["category_parent"]=> | |
int(0) | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment