Community Forums › Forums › Archived Forums › General Discussion › Can you help spot the error in my setup function?
- This topic has 3 replies, 2 voices, and was last updated 8 years, 1 month ago by yvonne.
-
AuthorPosts
-
February 8, 2016 at 2:40 pm #178601yvonneMember
I am trying to setup some of my child theme functions in my functions.php
file for my child theme using the genesis_setup. I am using the Genesis Sample child theme on a local install.When I include the functions for registering widget areas, it does not
work and the widgets do not show in the admin area. However, when I remove
those functions from the setup function they appear in the admin just fine. So I seem to
have a faulty setup function and I'm hoping someone can spot the issue. I
have consulted various tutorials to do this and I seem to have everything right but I cannot find my error. Can
you help spot my error? I can make them work if nobody can help but I would like to keep my code up to standards by using the setup function properly.The other code in my setup function - the "unregister layout" and
"unregister sidebar-alt" also don't work when inside this function but do
work when put outside of the function. So it is clearly my setup function
that is at fault somehow. I am not receiving any errors in the console.Here is my functions.php file in its entirety (after the opening php tag and the doc block):
//* Start the engine include_once( get_template_directory() . '/lib/init.php' ); //* Child theme (do not remove) define( 'CHILD_THEME_NAME', 'Home Free Theme' ); define( 'CHILD_THEME_URL', 'http://www.vonovo.ca/' ); define( 'CHILD_THEME_VERSION', '1.0.0' ); //* Enqueue Google Fonts add_action( 'wp_enqueue_scripts', 'hf_google_fonts' ); function hf_google_fonts() { wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700', array(), CHILD_THEME_VERSION ); } //* Add HTML5 markup structure add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) ); //* Add Accessibility support add_theme_support( 'genesis-accessibility', array( '404-page', 'headings', 'drop-down-menu', 'search-form', 'skip-links', 'rems' ) ); //* Add viewport meta tag for mobile browsers add_theme_support( 'genesis-responsive-viewport' ); //* Add support for custom background add_theme_support( 'custom-background' ); //* Add support for 3-column footer widgets add_theme_support( 'genesis-footer-widgets', 3 ); add_action( 'genesis_setup', 'homefree_setup', 15 ); /* Theme setup */ function homefree_setup() { //Unregister layouts that use secondary sidebar genesis_unregister_layout( 'content-sidebar-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' ); genesis_unregister_layout( 'sidebar-content-sidebar' ); //Unregister secondary sidebar unregister_sidebar( 'sidebar-alt' ); //add theme widget areas //include_once( get_stylesheet_directory() . '/includes/widget-areas.php' ); //* Register front page services widget area genesis_register_sidebar( array( 'id' => 'front-page-services-module', 'name' => __( 'Front Page Services', 'homefree' ), 'description' => __( 'This is a widget area for the services areas on the front page', 'homefree' ), ) ); //* Register consultation call-to-action widget area genesis_register_sidebar( array( 'id' => 'consult-cta', 'name' => __( 'Consultation CTA', 'homefree' ), 'description' => __( 'This is a widget area for the free consultation call-to-action', 'homefree' ), ) ); }
February 8, 2016 at 2:45 pm #178602yvonneMemberI should note that I am not receiving any errors in the console.
February 8, 2016 at 8:46 pm #178621Victor FontModeratorThere's no reason in a child theme to use genesis_setup or register sidebars in a function. Genesis_setup is called in the framework to initialize the default widget areas, i.e. header-right, sidebar, and sidebar-alt.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?February 9, 2016 at 8:31 am #178652yvonneMemberInteresting Victor. Thanks for your reply. I was following several tutorials, including one on lynda.com, all of which used this method, making sure to set a priority on the child setup function to make sure it loaded at the proper time. However, they are somewhat dated (2014) as that's the most recent I could find. Has the standard changed since then?
Regardless though, the jist is that it's considered ok to not have the child setup function?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.