daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Create ACF field called `widget_class` and assign to all widgets to use this function
  2.  
  3. add_filter('dynamic_sidebar_params', 'my_dynamic_sidebar_params');
  4.  
  5. function my_dynamic_sidebar_params($params)
  6. {
  7.     if ($params[0]['id'] != 'footer') return $params;
  8.  
  9.     $widget_id = $params[0]['widget_id'];
  10.  
  11.     $classes = get_field('widget_class', 'widget_' . $widget_id);
  12.  
  13.     if ($classes) {
  14.  
  15.         $params[0]['before_widget'] = str_replace('col-xs-12', $classes, $params[0]['before_widget']);
  16.  
  17.     }
  18.     return $params;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top