This is how you change the number of columns for similar products.

Marc Wagner, July 22, 2022

You can sim­ply chan­ge the num­ber of pro­ducts that are dis­play­ed via a plug­in or with PHP.

Sin­ce only a small code snip­pet is nee­ded for the chan­ge, it is recom­men­ded to imple­ment the who­le thing with PHP.

In the Functions.php of your Child The­me, you can insert the fol­lo­wing code to influence the num­ber and colum­ns:

/**
 * Change number of related products on product page
 */
function related_products_columns( $args ) {
   $args['posts_per_page'] = 4; // 4 related products
   $args['columns']        = 4; // arranged in 4 columns

   return $args;
}

add_filter( 'woocommerce_output_related_products_args', 'related_products_columns' );

That was it. Now you can cus­to­mi­ze your sel­ec­tion accor­ding to your wis­hes.

Avatar of Marc Wagner
Marc Wagner

Hi Marc here. I'm the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.

Similar Topics

Comments

Leave A Comment