Displays a list of links to all the terms from a specific WooCommerce product attribute via shortcode.
Perfect if, for example, you have a brands attribute with several brand terms (e.g. Apple, Microsoft) and you want to display a list of all the brand terms from this attribute with links to a page containing all products from a particular brand term. Maybe you have a color attribute, you can quickly add a list of all the colors from your store so a customer can click through and see all products that are a particular color.
We created this plugin out of neccessity because WooCommerce includes a “Filter products by attribute” widget, however this has a list of attribute terms which gets reduced once a term is clicked because the terms available are based on the products currently filtered (which could have other filters applied for category and other attributes). We needed to display a static list of terms which does not reduce as you click the terms to include in the footer of a website, we have also added the option to choose whether the term link should be a shop filter or an archive based link.
You can add the shortcode anywhere in your site, such as in pages, posts, widgets and directly in templates using do_shortcode (see FAQs).
The shortcode is:
Replace x with your attribute name as shown on the WooCommerce edit attribute page.
Use the shortcode attributes below as needed, optional attributes do not need to be included in your shortcode if you wish to use the defaults:
REQUIRED – The name of your product attribute, use name as shown on the WooCommerce edit attribute page, default is empty
OPTIONAL – Use any orderby parameter, default is name
OPTIONAL – Use asc or desc, default asc
OPTIONAL – Use 1 to hide empty terms, 0 to disable, default is 1
OPTIONAL – Use 1 to enable a count next to each term, 0 to disable, default is 0
OPTIONAL – Use 1 to enable archive links on each term like /brand/sega, 0 to disable for links like /shop/?filter_brand=sega, default is 0
OPTIONAL – Use a number to enable links to include a minimum price filter, requires archive_links to be 0, default is empty
OPTIONAL – Use a number to enable links to include a maximum price filter, requires archive_links to be 0, default is empty
If you have a brand attribute, this shortcode will display all brand term links ordered by name in ascending order, hides links which contain no terms and shows a count of the terms next to the term link:
[wcpas_product_attributes attribute="brand" orderby="name" order="asc" hide_empty="1" show_counts="1"]
- WordPress 5.0 or greater
- PHP 7.0 or greater
- WooCommerce must be installed and activated, we recommend using the latest version
To do an automatic install of this plugin log in to your WordPress dashboard, navigate to the Plugins menu, and click “Add New”.
Search for “Product Attributes Shortcode”, find this plugin in the list and click the install button, once done simply activate the plugin.
Manual installation method requires downloading the plugin and uploading it to your web server via an FTP application. See these instructions on how to do this.
Once you have installed and activated the plugin simply use the shortcode in pages, posts, widgets, templates, etc.
The list will not include links on the terms if you are using the archive_links attribute AND your attribute does not have the “Enable Archives?” setting enabled (Products > Attributes > Click “Edit” under the attribute name).
The default links (unless using the archive_links attribute) are filter based links which use your shop page, if you have not setup and assigned a shop page (which is usually done during WooCommerce installation but can also been done later via the WooCommerce status section) then your links may not work as it relies on the shop page existing and being assigned as the shop page in WooCommerce.
min_price and max_price are not working?
These are filter based and therefore require the archive_links attribute to be 0.
Can I use it in a page/post/widget/etc?
Yes, you can use the shortcode anywhere in WordPress where you can normally use shortcodes.
How can I get it to work in a template?
You will need to use the do_shortcode function. See this link for a code snippet (you’ll need to replace the shortcode with ours)
How do I style it?
You can custom CSS in your theme or via the customizer, each list is a
<ul>element with the class
.wcpas-product-attributes, to target specific attribute lists we have also included an ID of
Colaboradores y desarrolladores
«Product Attributes Shortcode» es un software de código abierto. Las siguientes personas han colaborado con este plugin.Colaboradores
¿Interesado en el desarrollo?
Registro de cambios
1.4.0 – 2022-04-23
- Added: Escaping of URLs, attributes and overall attributes list markup
- Changed: WordPress tested up to 5.9.3
1.3.0 – 2022-03-25
- Added: wcpas_product_attributes_translation function
- Added: WooCommerce not installed/activated notice
- Changed: WordPress tested up to 5.9.2
- Fixed: Translations may not load due to load_plugin_textdomain not hooked on init
1.2.0 – 2021-07-16
- Added: min_price attribute (archive_links must be false to use)
- Added: max_price attribute (archive_links must be false to use)
1.1.0 – 2021-05-12
- Added: archive_links attribute
- Changed: Default link used is a filter based term link
1.0.0 – 2021-05-11
- Initial release