I’ve been trying to create a shortcode with parameters to show me the categories of products. can anybody help me?
In functions.php
function shortcode_Paramet( $atts ) {
extract( shortcode_atts( array(
'titulo'=> 'Products',
'taxonomy' => 'product',
'number' => '2'
), $atts ) );
$out='<div>
<div>
<ul>
<li>Título:'.$titulo.'</li>
<li>Taxonomía:'.$taxonomy.'</li>
<li>Number:'.$number.'</li>
</ul>
</div>
</div>';
return $out;
}
add_shortcode( 'details', 'shortcode_Paramet' );
// Taxonomy
function crear_taxonomia() {
register_taxonomy('product', 'post', array( 'hierarchical' => false, 'label' => 'Product', 'query_var' => true, 'rewrite' => true));
}
add_action('init', 'crear_taxonomia', 0);
]]>
[product_categories number="12" parent="0"]
Just check all the available shortcode in Woocommerce https://docs.woocommerce.com/document/woocommerce-shortcodes/.
Thanks
Mohammad
function shortcode_Paramet( $atts ) {
extract( shortcode_atts ( array(
'style' => 'list',
'taxonomy' => 'product_categories',
),$atts));
echo get_the_category_list($atts);
}
]]>
Thanks
Mohammad