Archived topic
Footer Widget Setup
9 replies · Started by David Harper on June 12, 2015
Hi tom,
I was wondering if the Footer Widgets 0-5 could be manipulated so that I could each widget a specific width?
So for example instead of having 3 widgets by default/Global setting; I could use 2 footer widgets where the width of 1 is two-thirds of the footer width and the remaining widget spans the last one-third?
Or If I wanted the default setting of 3 footer widgets inline and a possible 4th the 3 default widgets that, again spans the full width of the footer section.
Here's two examples if my explanation wasn't clear enough: http://i.imgur.com/pBHBGwK.png?1
Cheers.
Absolutely! Each widget has a filter for the width.
For example:
add_filter( 'generate_footer_widget_1_width','generate_custom_footer_widget_1_width' );
function generate_custom_footer_widget_1_width()
{
// 25%
return '25';
}
add_filter( 'generate_footer_widget_2_width','generate_custom_footer_widget_2_width' );
function generate_custom_footer_widget_2_width()
{
// 20%
return '20';
}
add_filter( 'generate_footer_widget_3_width','generate_custom_footer_widget_3_width' );
function generate_custom_footer_widget_3_width()
{
// 15%
return '15';
}
add_filter( 'generate_footer_widget_4_width','generate_custom_footer_widget_4_width' );
function generate_custom_footer_widget_4_width()
{
// 20%
return '20';
}
add_filter( 'generate_footer_widget_5_width','generate_custom_footer_widget_5_width' );
function generate_custom_footer_widget_5_width()
{
// 20%
return '20';
}
Typically, you want them to add up to 100%, but I'm sure you could do some cool stuff like your second example :)
Cheers Tom,
much appreciated bud.
Happy to help :)
where to add the Each widget filter for the width in the theme. Is it in custom CSS or to create a child theme and change it or edit the footer widget php.
This should help: https://generatepress.com/knowledgebase/adding-php-functions/
Sorry to revive this old thread but I just want to clarify: If I wanted to make my footer widget spaces stay in a single row on a smaller screen, I could paste that PHP you provided into the Code Snippets Plugin window, adjust the percentages to whatever I liked (that added to 100), and save and refresh?
Furthermore, I currently only have three footer spaces, but would like to be able to easily add more in the future. Could I just comment out the code for spaces four and five like so:
*/ this is the code for footer spaces four and five */
?
I'm afraid of crashing my site and spending a lot of time trying to fix it later is why I'm asking rather than just trying.
Hi Mike,
So you don't want your footer widgets to stack on top of each other on mobile? It might be super squished if you force them to be next to each other?
You can add up to 5 footer widgets in the Customizer inside the "Layout" section: https://generatepress.com/knowledgebase/choosing-footer-widgets/
Hi Tom,
Not necessarily on a mobile screen. But even on my 13" screen, if I have the browser window any less than edge to edge, one container goes to the bottom, leaving an unsightly empty space to its right. I'd just like to reduce the amount of space that each container takes up, because it seems unreasonably large. I've adjusted the spacing down to 5px top and bottom, and 0px left and right in the element spacing>footer and footer widgets areas, and there's still way more blank space than I'm used to seeing in a footer box. I was hoping this was the solution.
Mostly, I love the theme. Thanks.
Hmm, I can't think of what the issue looks like - any chance you can share a link so I can see?
