Last active
July 23, 2022 09:09
-
-
Save Yorlinq/215e5dcfd54c8b5e08b80096fd9ef551 to your computer and use it in GitHub Desktop.
Shortcode for 'Product category name' by 'Product category id' - WooCommerce
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
// Shortcode for 'Product category name' by 'Product category id': [yl_product_category_name cat_id=''] | |
function yl_product_category_name_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'cat_id' => '', | |
), $atts ); | |
if ($term = get_term_by( 'id', $atts['cat_id'], 'product_cat' ) ){ | |
return $term->name; | |
} | |
} | |
add_shortcode('yl_product_category_name','yl_product_category_name_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment