• Resolved scamartist26

    (@scamartist26)


    I am doing some theme maintenance on a few older themes and need to add support for custom backgrounds. I found that the default background color is not working by itself. I mages work fine with this code, however, the color is not changing (nor does it work as a stand-alone default).

    Is this a bug? I have tested on v3.9 and other themes with the same problem.

    add_action( 'init', 'theme_custom_background');
    
    function theme_custom_background(){
    	$images_path = get_stylesheet_directory_uri().'/images';
    
    	$theme = genesis_get_option('bf_style_selection');
    
    	switch ($theme) {
    		case 'bf-blue':
    			$bg_color = 'def1fc';
    			$bg_image = $images_path.'/header-bg-blue.gif';
    			break;
    		case 'bf-black':
    			$bg_color = 'dadada';
    			$bg_image = $images_path.'/header-bg-black.gif';
    			break;
    
    	}
    
    	$defaults = array(
    	'default-color'          => $bg_color,
    	'default-image'          => $bg_image,
    	'default-repeat'         => 'repeat-x',
    	'default-position-x'     => 'top',
    	);
    
    	add_theme_support( 'custom-background', $defaults);
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter scamartist26

    (@scamartist26)

    Also, I know my code is not efficient, I just started writing it.

    Basically the following doesn’t work, but should:

    add_theme_support( 'custom-background', array( 'default-color' => '000000') );
    Thread Starter scamartist26

    (@scamartist26)

    Due diligence led me to the solution so I thought I should post back for anyone else that may come across this issue. Rather than duplicate it, here is the link to the stackoverflow answer.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom-background default-color not working’ is closed to new replies.