Community Forums › Forums › Archived Forums › General Discussion › 2 Widgets Areas Crashes Functions.php
- This topic has 5 replies, 2 voices, and was last updated 9 years, 10 months ago by Brad Dalton.
-
AuthorPosts
-
May 30, 2014 at 11:48 pm #107581mrhikingMember
I'm trying to add in 2 widget areas via functions.php. You'll see them both at the bottom of the code.
If I have both in, it crashes site. If I leave either in, it's fine. Help?<?php //* Start the engine include_once( get_template_directory() . '/lib/init.php' ); //* Child theme (do not remove) define( 'CHILD_THEME_NAME', 'Infinity' ); define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' ); define( 'CHILD_THEME_VERSION', '2.0.1' ); //* Enqueue Lato Google font add_action( 'wp_enqueue_scripts', 'infinity_google_fonts' ); function genesis_sample_google_fonts() { wp_enqueue_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,700', array(), CHILD_THEME_VERSION ); } //* Add HTML5 markup structure add_theme_support( 'html5' ); //* 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 ); genesis_register_sidebar( array( 'id' => 'home-top', 'name' => __( 'Home Top', 'infinity' ), 'description' => __( 'This is the home top section.', 'infinity' ), ) ); genesis_register_sidebar( array( 'id' => 'home-social', 'name' => __( 'Home Social', 'infinity' ), 'description' => __( 'This is the home social section.', 'infinity' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-left', 'name' => __( 'Home Middle Left', 'infinity' ), 'description' => __( 'This is the home middle left section.', 'infinity' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-right', 'name' => __( 'Home Middle Right', 'infinity' ), 'description' => __( 'This is the home middle right section.', 'infinity' ), ) ); genesis_register_sidebar( array( 'id' => 'home-bottom', 'name' => __( 'Home Bottom', 'infinity' ), 'description' => __( 'This is the home bottom section.', 'infinity' ), ) ); /** Add new image sizes */ add_image_size( 'mini-thumbnail', 75, 75, TRUE ); add_image_size( 'small-thumbnail', 110, 110, TRUE ); add_image_size( 'home-middle-left', 280, 165, TRUE ); add_image_size( 'home-middle-right', 50, 50, TRUE ); add_image_size( 'home-tabs', 150, 220, TRUE ); /** Add support for structural wraps */ add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'inner', 'footer-widgets', 'footer' ) ); /** Place Home Top Widget */ add_action( 'genesis_after_header', 'add_genesis_widget_area' ); function add_genesis_widget_area() { genesis_widget_area( 'home-top', array( 'before' => '<div class="home-top widget-area">', 'after' => '</div>', ) ); } /** Place Home Social */ add_action( 'genesis_before_content', 'add_genesis_widget_area' ); function add_genesis_widget_area() { genesis_widget_area( 'home-social', array( 'before' => '<div class="home-social widget-area">', 'after' => '</div>', ) ); }
May 31, 2014 at 2:17 am #107596Brad DaltonParticipant2 Things.
1. Once you embed code in a webpage it breaks. Please embed code correctly in these forums.
Github Gists are the best solution.
2. You cannot use the same function name which is why your code causes errors.
The reason i suggest using a Gist for embedded code is you'll find more people will help you if its easier to help and they can simply copy and paste your code into a text site. If they see the code like that, they know it is broken because of the way it is embedded incorrectly.
May 31, 2014 at 5:22 am #107610mrhikingMemberEh, sorry about that. I thought I was safe using the code embed on the forums. Lesson learned.
So, should I place that widget using Genesis Simple Scripts, or hard coding to the custom page I created?
May 31, 2014 at 5:51 am #107615Brad DaltonParticipantMay 31, 2014 at 5:54 am #107616mrhikingMemberSorry, Simple Hooks.
May 31, 2014 at 6:14 am #107619Brad DaltonParticipantI would simply change the name of the second function so its different to the 1st.
add_action( 'genesis_before_content', 'new_widget_area' ); function new_widget_area() {
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.