Custom Background
-
add_theme_support( 'custom-background' ); add_action( 'customize_register', 'custom_background_size' ); function custom_background_size( $wp_customize ) { $wp_customize->add_setting( 'default-size', array( 'default' => 'inherit', ) ); $wp_customize->add_control( 'default-size', array( 'label' => 'Background Image Size', 'section' => 'background_image', 'settings' => 'default-size', 'priority' => 200, 'type' => 'radio', 'choices' => array( 'cover' => 'Cover', 'contain' => 'Contain', 'inherit' => 'Inherit', ) )); } add_action( 'wp_head', 'custom_background_size_css', 999 ); function custom_background_size_css() { $background_size = get_theme_mod( 'default-size', 'inherit' ); echo '<style type="text/css"> body.custom-background { background-size:'.$background_size.'; } </style>'; }This is code i’m using that add custom background image to customizer (from codex) and additional size attribute.
Now i want it to hide along other controls when image is not specified but can’t find active_callback name for it.
Also i would like to move whole custom background section to panel. Tried :
add_theme_support( 'custom-background', $defaults ); $defaults = array( 'panel' => 'theme_settings' );but that’s not working. Any idea how can i get these 2 things work ?
Thanks@up
One more thing. How can i add section icons like in first screenshot here ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Custom Background’ is closed to new replies.