[Solved] I need some help on this code [closed]


I’ve added some comments to your ifs to explain them

// Extra post classes
$PHTclasses = array();

// if iterator is evenly divisible by # columns, or if there is only one column, add "first"
if ( 0 === ($woocommerce_loop['loop']) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] )
  $PHTclasses[] = 'first';

// if iterator is evenly divisible by # columns, add "last"
if ( 0 === ($woocommerce_loop['loop']) % $woocommerce_loop['columns'] )
  $PHTclasses[] = 'last';

So it seems logical to add another if block similar:

// if iterator is evenly divisible by 4
if ( 0 === ($woocommerce_loop['loop']) % 4 )
  $PHTclasses[] = 'mynewclass';

Note that the modulus operator % returns the remainder of the division operation, so if it’s working but it’s not getting the “right” sets of columns try changing the 0 to 1,2 or 3

1

solved I need some help on this code [closed]