2 Widgets Areas Crashes Functions.php

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

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  braddalton 4 months, 3 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #107581

    mrhiking
    Participant
    Post count: 48

    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>',
        ) );
    }
    
    #107596

    braddalton
    Participant
    Post count: 10217

    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.


    #107610

    mrhiking
    Participant
    Post count: 48

    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?

    #107615

    braddalton
    Participant
    Post count: 10217

    Whats Genesis Simple Scripts?


    #107616

    mrhiking
    Participant
    Post count: 48

    Sorry, Simple Hooks.

    #107619

    braddalton
    Participant
    Post count: 10217

    I would simply change the name of the second function so its different to the 1st.

    [php]
    add_action( ‘genesis_before_content’, ‘new_widget_area’ );
    function new_widget_area() {
    [/php]


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.