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

Marc Wag­ner

April 19, 2021

1 min read|

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.

88e86fcb816eff22bc917094df2862d8dd5c0e978b333e6dd5f36f808990c261 96

Arti­kel von:

Marc Wag­ner

Hi Marc here. I’m the foun­der of Forge12 Inter­ac­ti­ve and have been pas­sio­na­te about buil­ding web­sites, online stores, appli­ca­ti­ons and SaaS solu­ti­ons for busi­nesses for over 20 years. Befo­re foun­ding the com­pa­ny, I alre­a­dy work­ed in publicly lis­ted com­pa­nies and acqui­red all kinds of know­ledge. Now I want to pass this know­ledge on to my cus­to­mers.

Hast du eine Fra­ge? Hin­ter­lass bit­te einen Kom­men­tar