wc_get_loop_class

Get classname for loops based on $woocommerce_loop global.

Description

(string) wc_get_loop_class(); 

Returns (string)


Usage

  1. if ( !function_exists( 'wc_get_loop_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_get_loop_class(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function wc_get_loop_class() { 
  2. global $woocommerce_loop; 
  3.  
  4. $woocommerce_loop['loop'] = ! empty( $woocommerce_loop['loop'] ) ? $woocommerce_loop['loop'] + 1 : 1; 
  5. $woocommerce_loop['columns'] = max( 1, ! empty( $woocommerce_loop['columns'] ) ? $woocommerce_loop['columns'] : apply_filters( 'loop_shop_columns', 4 ) ); 
  6.  
  7. if ( 0 === ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] ) { 
  8. return 'first'; 
  9. } elseif ( 0 === $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) { 
  10. return 'last'; 
  11. } else { 
  12. return '';