Community Forums › Forums › Archived Forums › Design Tips and Tricks › Centric Pro – how do reduce footer widgets to 3?
Tagged: centric pro, customization, footer, widgets
- This topic has 3 replies, 2 voices, and was last updated 9 years, 1 month ago by
daymobrew.
-
AuthorPosts
-
January 27, 2016 at 7:55 am #177658
daymobrew
MemberCentric Pro 1.1 with Genesis 2.2.6.
I would like to reduce the number of footer widget areas from 3 to 4.
Rather than edit the Centric Pro files I have created a plugin. This is working quite well. For example, I added a stylesheet that depends on the Centric Pro one so is loaded after it.I have been able to reduce the footer widget area on the front end but not on the back end (it still shows 4 widget areas).
//add_action('after_theme_setup', 'rd_footer_widgets_count', 5); // This did not work add_action ( 'genesis_before_header', 'rd_footer_widgets_count', 2 ); function rd_footer_widgets_count() { // Change from 4 footer widgets to 3. remove_theme_support( 'genesis-footer-widgets' ); add_theme_support( 'genesis-footer-widgets', 3 ); }
I chose 'genesis_before_header' with a low priority because genesis_skip_links() is called in genesis/lib/structure/header.php to check whether footer widgets are supported.
I tried 'after_theme_setup' because it calls genesis_register_footer_widget_areas() with the default priority to call genesis_register_widget_area() for each required footer widget.I suppose that I could rename the 'footer-4' sidebar via the 'genesis_register_widget_area_defaults' filter, but that seems very hacky.
What hook should I be attaching to prevent the registration of widget area 'Footer 4'?
January 27, 2016 at 1:01 pm #177677Cathy @ WPBarista
MemberA plugin seems a long way around this one. Since footer widgets are always theme-dependent, is there a reason you don't just add that theme_support in the functions file? That will set the number of widgets in the front end and dashboard.
Visit WP Barista to download 52 Quick Edits You Can do Today to Get More Clicks / Views / Sales. I also do paid support (starting at $75) and fully custom Genesis Child Themes.January 27, 2016 at 2:09 pm #177689daymobrew
MemberMy plugin is only for use with Centric Pro. I don't want to edit the Centric Pro theme files - I do realise that it is unlikely to change but I want to the customisations the right way.
In centric-pro/functions.php it has
//* Add support for 4-column footer widgets add_theme_support( 'genesis-footer-widgets', 4 );
I am not exactly sure when this is run (it is not within an add_action function) so I have looked to see where the register_sidebar() function is called and working back from that.
genesis_register_widget_area() contains a call to register_sidebar()
genesis_register_footer_widget_areas() calls genesis_register_widget_area()
genesis_register_default_widget_areas() adds genesis_register_footer_widget_areas() to the 'after_theme_setup' hook.This last bit is why I was trying to call my function with the 'after_theme_setup' hook with an earlier priority.
January 27, 2016 at 3:09 pm #177693daymobrew
MemberI have figured out how/when to unregister_sidebar('footer-4'). Here is my full code:
// Change from 4 footer widgets to 3. Both add_action() calls are necessary. // This action sorts out the front end. add_action ( 'genesis_before_header', 'rd_footer_widgets_count', 2 ); function rd_footer_widgets_count() { // Change from 4 footer widgets to 3. remove_theme_support( 'genesis-footer-widgets' ); add_theme_support( 'genesis-footer-widgets', 3 ); } // This code unregisters the footer-4 sidebar for the backend. add_action('widgets_init', 'rd_disable_footer_widget_4', 1); function rd_disable_footer_widget_4() { unregister_sidebar('footer-4'); }
I tried using only the 'widgets_init' hook but the footer-4 sidebar is still rendered on the front end!!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.