Can't Register Genesis Sidebar – Fatal Error

Community Forums Forums Design Tips and Tricks Can't Register Genesis Sidebar – Fatal Error

This topic is: not resolved

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

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #107149

    anschoolfield
    Member
    Post count: 23

    I’m using Genesis 2.0.2 and Picture Perfect child theme from AgentEvolution.

    I want to add a new widget area to the left of the screen. I’ve used this tutorial numerous times on other sites and it’s worked every time. Now, when I put in the first snippet into my functions.php, I get this:

    Fatal error: Call to undefined function genesis_register_sidebar() in /home4/myamanda/public_html/test/wp-content/themes/picture-perfect/functions.php on line 90

    What do I need to do to register the function?

    http://test.myamandadesignplayground.com/
    #107162

    nutsandbolts
    Keymaster
    Post count: 3187

    I’m not familiar with that child theme, but some do things a little differently and require a different type of function. Can you paste in the functions.php from the child?


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #107163

    nutsandbolts
    Keymaster
    Post count: 3187

    You may need to try it like this:

    add_action( 'genesis_setup', 'nabm_banner' );
    function nabm_banner() {
    genesis_register_sidebar( array(
    	'id'		=> 'pagewidget',
    	'name'		=> __( 'Page Widget', 'nabm' ),
    	'description'	=> __( 'This is the widget area for a specific page.', 'nabm' ),
    ) );
    }

    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    • This reply was modified 5 months, 3 weeks ago by  nutsandbolts.
    • This reply was modified 5 months, 3 weeks ago by  nutsandbolts.
    #107166

    anschoolfield
    Member
    Post count: 23

    Sure,

    <?php
    /**
     * Functions
     *
     * PHP version 5
     *
     * @package  PicturePerfect/Setup
     * @author   Agent Evolution <support@agentevolution.com>
     * @license  http://www.gnu.org/copyleft/gpl.html GNU General Public License
     * @link     http://themes.agentevolution.com
     */
    
    if (defined('ABSPATH') === false) {
        die('Sorry, you are not allowed to access this file directly.');
    }
    
    define('AE_CHILD_THEME_NAME', 'Picture Perfect');
    define('AE_CHILD_THEME_SLUG', 'picture-perfect');
    
    require_once 'lib/classes/class-agentevo-helpers.php';
    require_once 'lib/classes/class-agentevo-customizer.php';
    require_once 'lib/classes/class-agentevo-nav-walker.php';
    require_once 'lib/functions/admin.php';
    require_once 'lib/functions/frontend.php';
    
    
    /**
     * Outputs the footer markup
     *
     * @return void
     */
    function picture_perfect_footer()
    {
        ?>
        <div class="one-half first footer-left">
            <?php echo do_shortcode(genesis_get_option('footer-left', 'agentevo-footer-settings')); ?>
        </div>
        <div class="one-half footer-right">
            <?php echo do_shortcode(genesis_get_option('footer-right', 'agentevo-footer-settings')); ?>
        </div>
        <?php
    
        $disclaimer = genesis_get_option('disclaimer', 'agentevo-footer-settings');
    
        if (false === empty($disclaimer)) {
            echo '
            <div class="footer-disclaimer">',
                do_shortcode(wpautop($disclaimer)),
            '</div>';
        }
    }
    
    
    # Include functions that should run in development only
    # Else serve css/style.css
    // if ( isset($_SERVER['SERVER_NAME']) && 'localhost' == $_SERVER['SERVER_NAME'] ) {
    // 	require_once 'lib/classes/class-agentevo-development-setup.php';
    // } else {
    // 	add_filter('stylesheet_uri', 'picture_perfect_stylesheet_uri', 10, 2);
    // }
    
    
    /**
     * Returns the path to the style.css file
     *
     * @return string path to the style.css file
     */
    function picture_perfect_stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri)
    {
    	return $stylesheet_dir_uri . '/style.css';
    }
    
    
    if ( ! get_option('picture_perfect_theme_activation') ) {
    
    	wp_remote_post(
    		'http://themes.agentevolution.com/child-theme-stats',
    		array(
    		 'body' => array(
    		 	 'theme' => 'picture_perfect',
    		 	 'url'   => $_SERVER['SERVER_NAME'],
    		 	)
    		)
    	);
    
    	add_option('picture_perfect_theme_activation', 'yes');
    }
    

    I’ve been adding the first snippet from your (awesome) tutorial at the very bottom. Usually I put it with the other register sidebar functions, but since there were no others I just put it at the bottom.

    Thanks Andrea!

    #107167

    nutsandbolts
    Keymaster
    Post count: 3187

    Yeah, that’s what I thought. See my previous response above for a snippet that should work with the child theme. This one uses a lot of additional files outside the main child theme directory – I did some work for a client on one with a similar setup and the one above worked.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #107171

    anschoolfield
    Member
    Post count: 23

    Alrighty,

    It’s not putting out Fatal Error anymore, so we’re close! Now to get it to show up what do I need to add to home.php?

    Here’s home.php:

    <?php
    /**
     * Home
     *
     * PHP version 5
     *
     * @package  PicturePerfect
     * @author   Agent Evolution <support@agentevolution.com>
     * @license  http://www.gnu.org/copyleft/gpl.html GNU General Public License
     * @link     http://themes.agentevolution.com
     */
    
    add_action('genesis_meta', 'picture_perfect_home_genesis_meta');
    
    /**
     * Add widget support for homepage. If no widgets active, display the default loop.
     *
     * @return void
     */
    
    function picture_perfect_home_genesis_meta()
    {
    	$sidebar_widget_areas = array(
    		'home-right',
    	);
    
    	if (false === any_picture_perfect_sidebar_is_active($sidebar_widget_areas)) {
    		add_filter('body_class', 'picture_perfect_blog_home_page_body_class');
    		return;
    	}
    
    	add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content');
    	remove_action('genesis_after_content', 'genesis_footer_widget_areas', 999);
    
    	# Custom body class
    	add_filter('body_class', 'picture_perfect_custom_home_page_body_class');
    
    	# Remove the loop and add a custom loop
    	remove_action('genesis_loop', 'genesis_do_loop');
    	add_action('genesis_loop', 'picture_perfect_home_loop_helper');
    }
    
    
    /**
     * Adds a custom body class on the home page
     *
     * @param array $classes the current body classes
     *
     * @return array modified classes
     */
    function picture_perfect_blog_home_page_body_class($classes)
    {
       $classes[] = 'blog-home-page';
       return $classes;
    }
    
    /**
     * Adds a custom body class on the home page
     *
     * @param array $classes the current body classes
     *
     * @return array modified classes
     */
    function picture_perfect_custom_home_page_body_class($classes)
    {
       $classes[] = 'custom-home-page';
       return $classes;
    }
    
    /**
     * Display widget content for homepage sections
     *
     * @return void
     */
    function picture_perfect_home_loop_helper()
    {
    	echo '<div class="home-right">';
    
    		picture_perfect_site_title_description_markup();
    
    		if (is_active_sidebar('home-right')) {
    			dynamic_sidebar('home-right');
    		}
    }
    
    /**
     * Returns true if any of the picture_perfect sidebars are active
     *
     * @param array $sidebar_widget_areas registered sidebars for use on home page
     *
     * @return bool
     */
    function any_picture_perfect_sidebar_is_active($sidebar_widget_areas)
    {
    	foreach($sidebar_widget_areas as $sidebar) {
    		if ( is_active_sidebar($sidebar) ) {
    			return true;
    		}
    	}
    
    	return false;
    }
    
    genesis();
    

    I only want it to show up on the home page.

    Thanks!!

    • This reply was modified 5 months, 3 weeks ago by  anschoolfield.
    • This reply was modified 5 months, 3 weeks ago by  anschoolfield.
    #107173

    nutsandbolts
    Keymaster
    Post count: 3187

    I’m guessing the theme has a home.php already? If so, my tutorial won’t help you much since it depends on your template (assuming you’re using a widgetized homepage and not a static page). If you can paste in the current home.php I’ll try to help you get it working. Alternately, you can call it from functions.php with a conditional to display only on the homepage.

    Edit: I see you beat me to it. Looking now :)


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    • This reply was modified 5 months, 3 weeks ago by  nutsandbolts.
    • This reply was modified 5 months, 3 weeks ago by  nutsandbolts.
    #107175

    nutsandbolts
    Keymaster
    Post count: 3187

    So where exactly does this need to show in relation to what’s on the homepage already?


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #107176

    anschoolfield
    Member
    Post count: 23

    Well, I can style it in CSS once it shows up, but basically I want it on the left, vertically centered. I’m going to put a call to action quote and button there.

    #107177

    nutsandbolts
    Keymaster
    Post count: 3187
    This reply has been marked as private.
    #107178

    anschoolfield
    Member
    Post count: 23
    This reply has been marked as private.
Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.