You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get the product attributes to be shown on the short description on the single productpage. I have found a code on this site, that is doing the trick. The only problem is that it if I use the shortcode in the description of the product, you don't see the language tags "[:en]tekst[:]" but if I add the function to 'woocommerce_single_product_summary', it does show me the language tags.
So my question is where does it goes wrong?
This is the code that I have been using (with thanks to: Rachel McCollin):
`
/**
Displays product attributes in the top right of the single product page.
@param $product
*/
function tutsplus_list_attributes( $product ) {
global $product;
global $post;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
return;
}
foreach ( $attributes as $attribute ) {
// Get the taxonomy.
$terms = wp_get_post_terms( $product->id, $attribute[ 'name' ], 'all' );
$taxonomy = $terms[ 0 ]->taxonomy;
// Get the taxonomy object.
$taxonomy_object = get_taxonomy( $taxonomy );
// Get the attribute label.
$attribute_label = $taxonomy_object->labels->name;
// Display the label followed by a clickable list of terms.
echo get_the_term_list( $post->ID, $attribute[ 'name' ] , '<div class="attributes">' . $attribute_label . ': ' , ', ', '</div>' );
HI,
I'm trying to get the product attributes to be shown on the short description on the single productpage. I have found a code on this site, that is doing the trick. The only problem is that it if I use the shortcode in the description of the product, you don't see the language tags "[:en]tekst[:]" but if I add the function to 'woocommerce_single_product_summary', it does show me the language tags.
So my question is where does it goes wrong?
This is the code that I have been using (with thanks to: Rachel McCollin):
`
/**
Displays product attributes in the top right of the single product page.
@param $product
*/
function tutsplus_list_attributes( $product ) {
global $product;
global $post;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
}
foreach ( $attributes as $attribute ) {
}
}
add_shortcode( 'display_attributes', 'tutsplus_list_attributes' );
add_action( 'woocommerce_single_product_summary', 'tutsplus_list_attributes' );
`
The text was updated successfully, but these errors were encountered: