admin管理员组文章数量:1122846
From my research there are only two questions I've found around this topic on this site:
- How to change in customizer the “site identity” tab required capabilities
- how to change default icon of custom plugin?
outside of the site I did find:
- How to Add a Default Site Icon in Theme's Customizer
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":
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.
From my research there are only two questions I've found around this topic on this site:
- How to change in customizer the “site identity” tab required capabilities
- how to change default icon of custom plugin?
outside of the site I did find:
- How to Add a Default Site Icon in Theme's Customizer
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":
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 Answers
Reset to default 0You 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' );
The site icon is not a theme setting, so the the theme should not be supplying a default.
edit: source: Wordpress Theme Handbook - Customizer Objects
Note: themes generally should not modify core sections and panels with the get methods, since themes should not modify core, theme-agnostic functionality. Plugins are encouraged to use these functions where necessary. Themes should not “reorganize” customizer sections that aren’t added by the theme.
本文标签: How can a default site icon be set in customizer
版权声明:本文标题:How can a default site icon be set in customizer? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736295473a1929577.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_setting
. – user9447 Commented Jan 9, 2019 at 18:07