ControlledChaos
5/7/2015 - 8:56 AM

Add Last Class to Footer Widget

Add Last Class to Footer Widget

<?php

function ccd_footer_widgets( $params ) {	 

  global $footer_widget_num;

  if( isset( $params[0]['id'] ) && $params[0]['id'] == 'footer_sidebar' ) {
    $footer_widget_num++;
    $divider = 3;
    
    if( $footer_widget_num % $divider == 0 ) {
      $class = 'class="last '; 
      $params[0]['before_widget'] = str_replace( 'class="', $class, $params[0]['before_widget'] );
    }
  }
  return $params;
}
add_filter( 'dynamic_sidebar_params','ccd_footer_widgets' );

?>

Add Last Class to Footer Widget

WordPress Snippet