WooCommerce list products by attribute with multiple values

Remi | August 2, 2013 | in Free

By default WooCommerce allows you to list products by attribute using this shortcode: [product_attribute attribute=’color’ filter=’black’], but this shortcode accepts only one single value for your attribute. That means that this shortcode [product_attribute attribute=’color’ filter=’black,red,white’] will not return anything.

That’s why i coded this small plugin that will allow you to set as many values for your attribute as you want. To use, simply place this shortcode:

[woo_products_by_attributes attribute=”colour” values=”red,black” per_page=”5″]

Remember, you can define only one attributes, but this attribute can have as many values as you want!

The author

About the author Remi: Hey! My name is Rémi Corson, i'm a WordPress Expert Developer, i create high level themes and plugins, and i provide free stuff every week on this website!


  1. Peter Sejersen

    Really nice work. I can definitely see this work – eg. for making awesome landing pages with specific products.

    Another question regarding attributes: Is it possible in some way to turn the product attributes in the Additional information tab into links? I would like to be able to click on the an attribute value on the product page and then come to an archive page of some sort, where I can see all products with this attribute.

    I know this is maybe a bit off topic, but you can maybe use it as an idea for a future post :-) I think it is something all WooCommerce shop users could benefit from.

  2. Johann

    good work,
    we search for a Product Tag Cloud, which loads Product Tags dynamically -depending what Attribute/Product Category or Taxonomy is choosen by users..

    example: clicking on Product Category XY -> all Product Tags from the Products in the Category are loaded in a widget..
    (same as woo layered navigation, but with product-tags&Cloud)

    If you want to do such a (paid) Cloud please contact me, thanks johann

  3. Yonathan

    Hi Remi,

    Can I display products without a custom attribute, so example:

    [woo_products_by_attributes attribute=”colour” values=”” per_page=”5″]

    so that the page will display products without colour attributes?

    Thanks in advance :)

  4. jamesdean

    Hi Remi,

    Nice plugin, thankyou.

    We would like to filter using two attributes instead of one, for example:
    – Colour: red, green
    – Size: S,M,L.

    So display for example all of the products that are red and size S.

    Any idea of how could we do that?

    Thanks in advance.

  5. mikehaceman

    I know it is probably stupid question. But how you implement this code? I am not a coder but would like to use this piece of work. Do you have some steps by steps guide?


    1. Jhonnu

      Hi mikehaceman,
      Any code that starts with * Plugin Name:
      * Plugin URI:
      * Description:
      * Version:
      * Author:
      * Author URI:
      * Requires at least:
      * Tested up to:
      * Text Domain: –
      * Domain Path:

      ect is a plugin like those found in the wordpress repository however you have to turn it into a file yourself. You’d copy the entire code and paste to a text editor ( I’ve used texteditor on Mac). Go up to the file menu to choose formatting and make this plain text. Save with thexetention . php. Then zip to upload in th eupload plugins tab of your wp admin.

  6. dirtyfeeling

    Hey Remi, will this work to show a product list filtered in a page, and make this work with the attribute filter of the sidebard? (like the default shop or a category page)

  7. manyakama

    Hi Remi,

    Here is my shortcode:

    [woo_products_by_attributes attribute=”szintek” values=”1. szint – Kezdő” per_page=”50″ columns=”3″ orderby=”title” order=”desc”]

    but it isn’t work. Is it correct?
    Or maybe it can work just in the shop pages? and in any other pages not?

  8. elise

    Dear Sir,
    Does this plugin support multiple attributes filtering?

    For an instance, initial example is:
    [woo_products_by_attributes attribute=”colour” values=”red,black” per_page=”5″]
    where only one attribute is involved in filtering.

    And the thing I’m looking for possibly would look somehow like:

    [woo_products_by_attributes attribute=”colour” values=”red” && attribute= “size” value=”large” per_page=”5″]

    where the filtering is taking place by two attributes simultaneously.

    If it doesn’t, then could you please help me out with this. I would highly appreciate it.

  9. jamesdean

    Hi Remi,

    How could we display 5 columns instead of 4?

    I’ve managed to change the number of columns in the shortcode “[product_category category ” by adding the css code:

    .woocommerce.columns-5 .products .product {
    position: relative;
    width: 16.5%;

    I’ve tried to change the number of columns in your plugin but instead of 5 it displays 3 and 2. Maybe I should change the css somewhere but I don’t know exactly where.

    Could you please give me a tip?

    Kind regards.

  10. dademaru

    Hi Remi,

    is this shortcode working with WC 2.2.x?
    I’ve tried using different values but I get only one product.
    Maybe it displays only the product that has all this values?
    The logic should be OR, not AND, so if colors are blue, green, red, display the products that have green attribute, the products with blue attribute, …
    not only the product that has all these attribute.
    Could this be the reason why I have only one product displayed?

  11. xtobix

    Hi Remi, where do I include the plugin code above? Do I need to create a new folder in the plugins folder? Sorry for the question but I never worked with custom plugins before. Thanks in advance!

    1. Remi Post author

      Hey, you create a folder in wp-content/plugins, name it whatever you want, and create a new file in this folder. Place the code in that file and you’re good to go!

  12. Pingback: Jesse Pearson on "[Plugin: WooCommerce - excelling eCommerce] Related products bu attribute value" * Best Wordpress Themes - Reviews

  13. vinay

    Hi Remi,

    Thanks for posting such a wonderful article, it has really solved my problem, i am using your code and i’ve made few more changes in it for some other attributes as well. I am using it very well, but i got stuck with something, i am passing values to this plugin in php on run time via AJAX and its working fine however the only problem is that when i am passing values during run time via ajax call, the pagination doesn’t works.

    What i am doing is that, i have two different product one is main and nother is an addon on that so in single product page I am listing various addon products along with there prices but since that list is long i am not able to paginate them. so that i can move forward with other addon product and check which fits with the current product.

    So how can i do the pagination when i pass values during runtime.


Leave a reply