admin管理员组文章数量:1382513
I have a WordPress site, with WooCommerce. The WooCommerce archives pages as shop display a dropdown sorting filter like in this screenshot:
Now in another page let's say example/foo
On that page I use a WooCommerce shortcode:
[product_category per_page="90" columns="3" orderby="" order="ASC" category="foo" prdctfltr="yes" pagination="yes"]
But the sorting dropdown is not shown.
What I am doing wrong? How can I display the sorting dropdown?
I have a WordPress site, with WooCommerce. The WooCommerce archives pages as shop display a dropdown sorting filter like in this screenshot:
Now in another page let's say example/foo
On that page I use a WooCommerce shortcode:
[product_category per_page="90" columns="3" orderby="" order="ASC" category="foo" prdctfltr="yes" pagination="yes"]
But the sorting dropdown is not shown.
What I am doing wrong? How can I display the sorting dropdown?
Share Improve this question edited May 6, 2019 at 23:46 LoicTheAztec 3,39117 silver badges24 bronze badges asked May 6, 2019 at 20:56 TheGejrTheGejr 331 gold badge1 silver badge4 bronze badges2 Answers
Reset to default 4Since WooCommerce 3.2, Woocommerce shortcodes and their available attributes have changed.
So try the following shortcode instead (for "foo" product category):
[product_category limit="90" columns="3" category="foo" paginate="true"]
or inside php code:
echo do_shortcode( '[product_category limit="90" columns="3" category="foo" paginate="true"]' );
Now you will see that the sorting options dropdown appear.
Note: orderby
argument with an empty value has no effect. order
argument is ASC
by default.
If you would rather want to get the sorting menu using a shortcode then you can create one for it in your functions.php
// Creating Shortcode for Product Sorting
add_shortcode('wc_sorting','woocommerce_catalog_ordering');
Then simply call the shortcode in your catalog page:-
- In Legacy Editor/Gutenberg:
[wc_sorting]
- or in your PHP file:
echo do_shortcode('[wc_sorting]');
本文标签: phpDisplay sorting options dropdown when using WooCommerce product category shortcode
版权声明:本文标题:php - Display sorting options dropdown when using WooCommerce product category shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744511364a2609904.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论