Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Shortcodes changes in 3.2.0
Table of Contents
- Replaced shortcode attributes.
- Products shortcode
Shortcodes has been improved on WooCommerce 3.2.0, see the changes:
Replaced shortcode attributes.
Some of the attributes have gained a new names.
per_pagenow is called
operatornow is called
filternow is called
All changes has been made to make the attributes clearer and easier to use.
Note that the old names will still work without generating any warning or deprecated notice.
[products] shortcode has been improved on WooCommerce 3.2, allowing fetch products by ids, SKUs, categories, attributes, and more, replacing the need for multiples shortcodes like
limit- Results limit. Defaults to
columns- Number of columns. Defaults to
orderby- Sort retrieved products by parameter. Available options:
id. Defaults to
title. One or more options can be passed separated by empty spaces.
order- Designates the order of the
orderbyattribute. Available options:
DESC. Defaults to
ids- Comma separated list of product IDs.
skus- Comma separated list of product SKUs.
category- Comma separated list of category slugs.
cat_operator- Operator to compare categories. Available options:
NOT IN. Defaults to
attribute- Retrieved products based on an attribute slug.
terms- Comma separated list of attribute terms to be used with
terms_operator- Operator to compare attribute terms. Available options:
NOT IN. Defaults to
visibility- Retrieve products based on visibility. Available options:
visible(visible on shop and search results),
catalog(visible on shop only),
search(visible on search results only), and
hidden. Defaults to
class- Shortcode wrapper HTML class.
on_sale- Retrieve on sale products. Not to be used in conjunction with
best_selling- Retrieve best selling products. Not to be used in conjunction with
top_rated- Retrieve top rated products. Not to be used in conjunction with
Check the follow examples that replaces our old shortcodes.
Products by category
[products category="clothing" limit="4" orderby="menu_order title" order="ASC"]
Products by attribute
[products attribute="color" terms="black" limit="4" orderby="title" order="ASC"]
Products by ID
Products by SKU
[products limit="4" orderby="date" order="DESC"]
On sale products
[products on_sale="true" limit="4" orderby="title" order="ASC"]
Best selling products
[products best_selling="true" limit="4"]
Top rated products
[products top_rated="true" limit="4" orderby="title" order="ASC"]
[products visibility="featured" limit="4" orderby="date" order="DESC"]