• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

2 Widgets Areas Crashes Functions.php

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › 2 Widgets Areas Crashes Functions.php

This topic is: not resolved
  • This topic has 5 replies, 2 voices, and was last updated 11 years, 8 months ago by Brad Dalton.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • May 30, 2014 at 11:48 pm #107581
    mrhiking
    Member

    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 #107596
    Brad Dalton
    Participant

    2 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.


    Tutorials for StudioPress Themes.

    May 31, 2014 at 5:22 am #107610
    mrhiking
    Member

    Eh, 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 #107615
    Brad Dalton
    Participant

    Whats Genesis Simple Scripts?


    Tutorials for StudioPress Themes.

    May 31, 2014 at 5:54 am #107616
    mrhiking
    Member

    Sorry, Simple Hooks.

    May 31, 2014 at 6:14 am #107619
    Brad Dalton
    Participant

    I 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() {
    

    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble