By DᴀʀᴛʜVᴀᴅᴇʀ


2019-01-09 17:14:12 8 Comments

From my research there are only two questions I've found around this topic on this site:

outside of the site I did find:

but when I try:

function default_icon() {
  global $wp_customize;
  $wp_customize->get_setting('site_icon',array (
    'default' => home_url() . 'img/test.png'
  ));
}
add_action('customize_register','default_icon');

I've also tried add_setting with:

function default_icon() {
  global $wp_customize;
  $wp_customize->add_setting('site_icon', array(
    'default' => home_url() . 'img/test.png'
));
}
add_action('customize_register','default_icon');

but that doesn't work either. It will not show the default icon in the drag and drop area and renders "No Image selected":

enter image description here

In my functions.php how can I code my theme to render the default icon presently being used in the drag and drop area?

After further testing I can set the default when I code:

add_action('customize_register','default_icon',10,2);

and I can see it in a dump of $wp_customize but as far as rendering it will not.

2 comments

@Joy Reynolds 2019-01-10 21:18:07

The site icon is not a theme setting, so the the theme should not be supplying a default.

@Krzysiek Dróżdż 2019-01-09 17:56:04

You can see the customizer API to set default icon. This should do the trick, I guess:

function mytheme_customize_register( $wp_customize ) {

    $wp_customize->add_setting( 'site_icon' , array(
        'default'     => get_bloginfo('template_url') . '/images/logo.png',
    ) );

}
add_action( 'customize_register', 'mytheme_customize_register' );

@DᴀʀᴛʜVᴀᴅᴇʀ 2019-01-09 18:43:09

Thanks for trying but I've already tried that approach, edited question to show code, also note that you need to call global $wp_customize or you'll error out.

@Krzysiek Dróżdż 2019-01-09 20:32:32

@DᴀʀᴛʜVᴀᴅᴇʀ You're right. It works in that sense it really sets the default value for that setting - you can see it var_dumping $wp_customize object, but it doesn't change the value of control...

@DᴀʀᴛʜVᴀᴅᴇʀ 2019-01-09 23:16:23

Ya but that still doesn't solve the question

@Krzysiek Dróżdż 2019-01-09 23:18:29

@DᴀʀᴛʜVᴀᴅᴇʀ I know - I’ll leave it here so I can get back to it tomorrow

Related Questions

Sponsored Content

1 Answered Questions

Set Site Icon programmatically (eg. using `wp cli`)

1 Answered Questions

[SOLVED] Customizer notifications for disabled and hidden controls

1 Answered Questions

How to add a Visual Edit Shortcut to a theme mod?

  • 2017-07-10 14:38:06
  • Hristiyan Dodov
  • 254 View
  • 0 Score
  • 1 Answer
  • Tags:   theme-customizer

1 Answered Questions

[SOLVED] Set Default Page On Customizer Live Preview

1 Answered Questions

[SOLVED] How to Add Customizer Setting in Child Theme

1 Answered Questions

[SOLVED] WP 4.5 hide core customizer sections

1 Answered Questions

[SOLVED] HTML output via Theme Customizer is not working

  • 2015-06-02 15:46:15
  • tsquez
  • 1468 View
  • 0 Score
  • 1 Answer
  • Tags:   theme-customizer

1 Answered Questions

[SOLVED] Widgets Section not displaying in theme customizer

1 Answered Questions

Sponsored Content