Start a project

Change the Number of Accessory Columns

Lets say you want to show 5 accessories in one row.

  • woocommerce_product_accessories_mandatory_display_args
  • woocommerce_product_accessories_optional_display_args

Then use this shortcode:

function we_modify_optional_accessory_columns( $args ) {
    $args['columns'] = 5;
    return $args;
};
// add the filter
add_filter( 'woocommerce_product_accessories_optional_display_args', 'we_modify_optional_accessory_columns', 60, 1 );

Questions & answers (4)

  1. ClausFebruary 21, 2022

    Hi! I have added this code as a snippet to my site. It works, I want and I have 3 colums. But when the snippet is enabled, the defined heading is missing. how can I fix this?

  2. ankushJune 8, 2020

    Kindly look at the link i provided. I have changed position of products successfully.
    But, not able to change view of products as per above shortcode.
    Kindly help in this matter.

  3. John MatherMarch 31, 2018

    Thanks for your excellent plugin. I followed the instructions for “Changing the Position” successfully but couldn’t make this work. Where should i place this code ? Regards, John

  4. weLaunchMarch 31, 2018

    Hi there,

    you need to place this into your functions.php of your child theme.