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


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.