Posted By

almendro on 06/13/13


Tagged

wordpress wp twentytwelve sidebar-footer


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

almendro


WP twentytwelve theme width sidebar footer again. Part 4: FUNCTIONS.PHP (again)


 / Published in: PHP
 

How to put sidebars footer on twenty twelve theme again. Part 4: Insert a new function (retouched from twentyeleven) in the functions.php file.

  1. /**
  2.  * Count the number of footer sidebars to enable dynamic classes for the footer
  3.  
  4.  Ported from twentyeleven by Martin Ochoa 2013-06-12
  5.  */
  6. function twentytwelve_footer_sidebar_class() {
  7. $count = 0;
  8.  
  9. if ( is_active_sidebar( 'sidebar-4' ) )
  10. $count++;
  11.  
  12. if ( is_active_sidebar( 'sidebar-5' ) )
  13. $count++;
  14.  
  15. if ( is_active_sidebar( 'sidebar-6' ) )
  16. $count++;
  17.  
  18. $class = '';
  19.  
  20. switch ( $count ) {
  21. case '1':
  22. $class = 'one';
  23. break;
  24. case '2':
  25. $class = 'two';
  26. break;
  27. case '3':
  28. $class = 'three';
  29. break;
  30. }
  31.  
  32. if ( $class )
  33. echo 'class="' . $class . '"';
  34. }

Report this snippet  

You need to login to post a comment.