• I am putting together a child theme for the Twenty Eleven theme and I wanted to have a header image that would change randomly. I installed the plugin “Add Custom Header Images” and it works pretty well. Unfortunately, however, the default header images that come with Twenty Eleven have included themselves in the group of header images I want to use.

    I found the images in the Twenty Twelve images folder and stored them elsewhere, thinking that, if the images couldn’t be found, it might solve the problem. But then I would just get some text when one of those images showed up.

    Then I found the section of the functions.php file that referenced those default images and I commented it out in the parent functions.php file. That worked great; but, of course, I really want to fix it in the child theme, not in the parent theme.

    I got in touch with Andy Fragen, the developer of the plugin, but he just said that I shouldn’t mess with the parent theme and that if I put everything back the way it was originally in the parent theme, it would work. Hmmm…

    So, clearly, if I want to use this plugin, which I do, I need to find a way to disable that section of the functions.php file in the child theme; but I haven’t got a clue how to do that since it is embedded in the middle of the first major function. Here is the pertinent section of the code (lines 178-228)

    // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    	register_default_headers( array(
    		'wheel' => array(
    			'url' => '%s/images/headers/wheel.jpg',
    			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Wheel', 'twentyeleven' )
    		),
    		'shore' => array(
    			'url' => '%s/images/headers/shore.jpg',
    			'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Shore', 'twentyeleven' )
    		),
    		'trolley' => array(
    			'url' => '%s/images/headers/trolley.jpg',
    			'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Trolley', 'twentyeleven' )
    		),
    		'pine-cone' => array(
    			'url' => '%s/images/headers/pine-cone.jpg',
    			'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Pine Cone', 'twentyeleven' )
    		),
    		'chessboard' => array(
    			'url' => '%s/images/headers/chessboard.jpg',
    			'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Chessboard', 'twentyeleven' )
    		),
    		'lanterns' => array(
    			'url' => '%s/images/headers/lanterns.jpg',
    			'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Lanterns', 'twentyeleven' )
    		),
    		'willow' => array(
    			'url' => '%s/images/headers/willow.jpg',
    			'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Willow', 'twentyeleven' )
    		),
    		'hanoi' => array(
    			'url' => '%s/images/headers/hanoi.jpg',
    			'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Hanoi Plant', 'twentyeleven' )
    		)
    	) );

    If I could make it look like this in the child theme…

    register_default_headers( array(
    	) );

    …then the plugin would work.

    Anyone know how I could do that?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disabling a section of functions.php, 2011’ is closed to new replies.