shortcode not working

I m working on content-product of woocommerce and doing shortcode in the template as echo do_shortcode ('[product_attribute attribute="Grams"]'); where Grams are in my backend as attribute and it hasvalues, but nothing get printed out.Is it a wrong query or i need to do something else?

Related posts

1 comment

  1. I may have found the problem (from product_attribute)

    array(
     'per_page' => '12',
     'columns' => '4',
     'orderby' => 'title',
     'order' => 'asc',
     'attribute' => 'asc',
     'filter' => 'asc'
    )
    
    [product_attribute attribute='color' filter='black']
    

    Notice the attibute is in single quotes wheras yours is in double quotes:

    do_shortcode ('[product_attribute attribute="Grams"]');
    

    also you may need it to be in lowercase letters.

    From The codex:

    IMPORTANT TIP – Don’t use camelCase or UPPER-CASE for your $atts attribute names
    $atts values are lower-cased during shortcode_atts( array( ‘attr_1’ => ‘attr_1 default’, // …etc ), $atts ) processing, so you might want to just use lower-case.

Comments are closed.