WordPress.org

Support

Support » Themes and Templates » [Resolved] TwentyTen child theme – adding widget areas via child's functions.php

[Resolved] TwentyTen child theme – adding widget areas via child's functions.php

  • Dear all, I am still struggling with the functions.php of my child theme…
    I am trying to override the widget call and add two more widget areas to my child thme via the functions.php. What is wrong with the following code (it just produces a blank output if added to the existing code in the – working – child theme functions.php)? http://wordpress.pastebin.com/NQUD9FSk

Viewing 4 replies - 1 through 4 (of 4 total)
  • OK; solved. The code to add must look something like that:

    add_action( 'init', 'header_widgets_init' );
    function header_widgets_init() {
    	// Area 7, located in the header. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'First Header Widget Area', 'twentyten' ),
    		'id' => 'first-header-widget-area',
    		'description' => __( 'The first header widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );	
    
    	// Area 8, located in the header. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Second Header Widget Area', 'twentyten' ),
    		'id' => 'second-header-widget-area',
    		'description' => __( 'The second header widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );	
    
    }

    nomolos

    @nomolos

    Hello I tried to follow your code to get the “above header” to work but no luck. Could you possibly post all the needed code and where each doc needs changing. Thank you so muc

    OR. If anyone else has the answer please let me know with full code changes .

    If your theme already supports sidebars (like twentyten and it’s child themes). You can just add:

    register_sidebar( array(
    		'name' => __( 'First Header Widget Area', 'twentyten' ),
    		'id' => 'first-header-widget-area',
    		'description' => __( 'The first header widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );	
    
    	// Area 8, located in the header. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Second Header Widget Area', 'twentyten' ),
    		'id' => 'second-header-widget-area',
    		'description' => __( 'The second header widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );

    Without action and function.

    But if you know would like to with an action, you could write:

    add_action( 'widgets_init', 'header_widgets_init', 11);

    nomolos

    @nomolos

    Thank you so much for your prompt reply.
    I have pasted code in functions php but have this error above header:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘header_widgets_init’ not found or invalid function name in /Applications/xampp/xamppfiles/htdocs/wordpress/wp-includes/plugin.php on line 395

    Line 395 is:

    call_user_func_array($the_[‘function’], array_slice($args, 0, (int) $the_[‘accepted_args’]));

    I am not capable enough with php to understand what now must be changed. Is “header_widgets_init” not an accepted arg and if so where can I change the args to make it work.

    Sorry for being so dumb but thank you so much for your really rapid reply.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] TwentyTen child theme – adding widget areas via child's functions.php’ is closed to new replies.
Skip to toolbar