Previously I wrote a tutorial “How to change the footer copyright text from Genesis Theme Settings Page“. Today I am writing this article and showing you how to change the footer widget area from Genesis Theme Settings page.
I added following PHP code in functions.php file:
Creating Theme Settings for Footer Widget
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
function gd_defaults_settings_fields( $default_settings ) { $default_settings['footer_widgets'] = 3; // default is 3 return $default_settings; } add_filter( 'genesis_theme_settings_defaults', 'gd_defaults_settings_fields' ); function gd_genesis_settings_sanitization_filters() { genesis_add_option_filter( 'no_html', GENESIS_SETTINGS_FIELD, array( 'footer_widgets' ) ); } add_action( 'genesis_settings_sanitizer_init', 'gd_genesis_settings_sanitization_filters' ); add_action('genesis_theme_settings_metaboxes', 'gd_add_metaboxes', 99, 1); function gd_add_metaboxes( $pagehook ){ if( is_admin() ): add_meta_box( 'genesis-theme-settings-footer-widgets', __( 'Footer Widget Settings', 'genesis_developer' ), 'gd_footer_widgets_box', $pagehook, 'main', 'high' ); endif; } // Footer Widgets UI function gd_footer_widgets_box(){ ?> <p> <label for="<?php echo GENESIS_SETTINGS_FIELD;?>[footer_widgets]"><?php _e( 'Footer Widgets:', 'genesis' ); ?></label> <select name="<?php echo GENESIS_SETTINGS_FIELD;?>[footer_widgets]" id="<?php echo GENESIS_SETTINGS_FIELD;?>[footer_widgets]"> <?php for($i=0; $i <= 6; $i++){ ?> <option value="<?php echo $i; ?>"<?php selected( $i, genesis_get_option( 'footer_widgets' ) ); ?>><?php echo $i; ?></option> <?php } ?> </select> </p> <?php } |
Adding Footer Widgets Support
1 2 3 4 5 6 7 8 9 10 11 12 |
//* Add support for flexible footer widgets $footer_widgets = ( intval( genesis_get_option('footer_widgets') ) > -1 ) ? genesis_get_option('footer_widgets') : 3 ; add_theme_support( 'genesis-footer-widgets', intval($footer_widgets) ); if( intval($footer_widgets) > 0 ){ add_filter( 'genesis_attr_footer-widgets', 'gd_genesis_attributes_footer_widgets' ); function gd_genesis_attributes_footer_widgets($attributes){ $attributes['class'] .= ' gd-footer-widgets-' . genesis_get_option('footer_widgets'); return $attributes; } } |
Styling for Responsive Effect
I added following CSS in style.css file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
/* 1 Column Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-1 .footer-widgets-1{ clear: both; display: table; float: none; width: 100%; } /* 2 Columns Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-2 .footer-widgets-1, .gd-footer-widgets-2 .footer-widgets-2{ width: 48.717948717948715%; } /* 3 Columns Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-3 .footer-widgets-1, .gd-footer-widgets-3 .footer-widgets-2, .gd-footer-widgets-3 .footer-widgets-3{ width: 31.623931623931625%; } /* 4 Columns Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-4 .footer-widgets-1, .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-3, .gd-footer-widgets-4 .footer-widgets-4{ width: 23.076923076923077%; } /* 5 Columns Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-5 .footer-widgets-1, .gd-footer-widgets-5 .footer-widgets-2, .gd-footer-widgets-5 .footer-widgets-3, .gd-footer-widgets-5 .footer-widgets-4, .gd-footer-widgets-5 .footer-widgets-5{ width: 18%; } /* 6 Columns Footer Widget ---------------------------------------------------------------------------*/ .gd-footer-widgets-6 .footer-widgets-1, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-5, .gd-footer-widgets-6 .footer-widgets-6{ width: 14.52991452991453%; } .gd-footer-widgets-2 .footer-widgets-1, .gd-footer-widgets-3 .footer-widgets-1, .gd-footer-widgets-3 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-1, .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-3, .gd-footer-widgets-5 .footer-widgets-1, .gd-footer-widgets-5 .footer-widgets-2, .gd-footer-widgets-5 .footer-widgets-3, .gd-footer-widgets-5 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-1, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-5{ float: left; margin-right: 2.5%; } .gd-footer-widgets-2 .footer-widgets-2, .gd-footer-widgets-3 .footer-widgets-3, .gd-footer-widgets-4 .footer-widgets-4, .gd-footer-widgets-5 .footer-widgets-5, .gd-footer-widgets-6 .footer-widgets-6{ float: right; } @media only screen and (max-width: 1023px) { .gd-footer-widgets-4 .footer-widgets-1, .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-3, .gd-footer-widgets-4 .footer-widgets-4{ float: left; margin-right: 2.5%; width: 48.717948717948715%; } .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-4{ float: right; margin-right: 0; } .gd-footer-widgets-6 .footer-widgets-1, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-5, .gd-footer-widgets-6 .footer-widgets-6{ float: left; margin-right: 2.5%; width: 31.623931623931625%; } .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-6{ float: right; margin-right: 0; } } @media only screen and (max-width: 900px) { .gd-footer-widgets-4 .footer-widgets-1, .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-3, .gd-footer-widgets-4 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-1, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-5, .gd-footer-widgets-6 .footer-widgets-6{ float: left; margin-right: 2.5%; width: 48.717948717948715%; } .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-6{ float: right; margin-right: 0; } .gd-footer-widgets-3 .footer-widgets-1, .gd-footer-widgets-3 .footer-widgets-2, .gd-footer-widgets-3 .footer-widgets-3, .gd-footer-widgets-5 .footer-widgets-1, .gd-footer-widgets-5 .footer-widgets-2, .gd-footer-widgets-5 .footer-widgets-3, .gd-footer-widgets-5 .footer-widgets-4, .gd-footer-widgets-5 .footer-widgets-5{ float: none; margin-right: 0; width: 100%; } } @media only screen and (max-width: 767px) { .gd-footer-widgets-2 .footer-widgets-1, .gd-footer-widgets-2 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-1, .gd-footer-widgets-4 .footer-widgets-2, .gd-footer-widgets-4 .footer-widgets-3, .gd-footer-widgets-4 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-1, .gd-footer-widgets-6 .footer-widgets-2, .gd-footer-widgets-6 .footer-widgets-3, .gd-footer-widgets-6 .footer-widgets-4, .gd-footer-widgets-6 .footer-widgets-5, .gd-footer-widgets-6 .footer-widgets-6{ float: none; margin-right: 0; width: 100%; } } |
Ken says
Thank You for this post Sir. I will be using this for all of my projects. GodBless
David says
Thanks! Worked great without any modification in the Parallax Pro theme.
Brenda Malone says
Excellent tutorial, I will implement on my sites. You are an excellent teacher and I wish you much success.
Paul says
Thank you