WP: Insert Multiple Sidebars


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



Copy this code and paste it in your HTML
  1. In functions.php:
  2.  
  3. // Add widget-ready sidebars
  4. if (function_exists('register_sidebar')) {
  5. register_sidebar(array(
  6. 'name' => 'Footer 1',
  7. 'id' => 'footer1',
  8. 'description' => 'These are widgets for the footer.',
  9. 'before_widget' => '',
  10. 'after_widget' => '',
  11. 'before_title' => '<h6>',
  12. 'after_title' => '</h6>'
  13. ));
  14. }
  15. if (function_exists('register_sidebar')) {
  16. register_sidebar(array(
  17. 'name' => 'Footer 2',
  18. 'id' => 'footer2',
  19. 'description' => 'These are widgets for the footer.',
  20. 'before_title' => '<h6>',
  21. 'after_title' => '</h6>'
  22. ));
  23. } if (function_exists('register_sidebar')) {
  24. register_sidebar(array(
  25. 'name' => 'Footer 3',
  26. 'id' => 'footer3',
  27. 'description' => 'These are widgets for the footer.',
  28. 'before_title' => '<h6>',
  29. 'after_title' => '</h6>'
  30. ));
  31. }
  32.  
  33. In sidebar.php:
  34.  
  35. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 1') ) : ?>
  36. <p>This area is widgetised! To make use of this area, put some widgets in the 'Main Sidebar' section.</p>
  37. <?php endif; ?>
  38.  
  39. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 2') ) : ?>
  40. <p>This area is widgetised! To make use of this area, put some widgets in the 'Main Sidebar' section.</p>
  41. <?php endif; ?>
  42.  
  43. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer 3') ) : ?>
  44. <p>This area is widgetised! To make use of this area, put some widgets in the 'Main Sidebar' section.</p>
  45. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.