我是Wordpress和PHP的新手,我正在尝试为memberlite主题创建子主题。我想在定制器中添加一个自定义配色方案,但是我不知道如何注销父主题的customizer.php,或者修改当前的配色方案。(我不确定哪种方法是正确的)。
在父主题functions.php中:
/* Customizer additions. */
require_once get_template_directory() . '/inc/customizer.php';理想情况下,我希望不需要该文件,并添加我自己的文件。
任何帮助都将不胜感激。
发布于 2018-07-30 00:07:17
要使用colorpicker添加设置,请尝试以下代码:
const COLOR_SECTION = "color_section";
const SETTING_COLOR1 = "color1";
add_action("customize_register", function (\WP_Customize_Manager $wp_customize) {
$wp_customize->add_section(
COLOR_SECTION
,
[
"title" => "Color section",
"priority" => 1,
]
);
$wp_customize->add_setting(
SETTING_COLOR1
,
[
"default" => get_theme_mod(SETTING_COLOR1),
"type" => "theme_mod",
]
);
$wp_customize->add_control(
SETTING_COLOR1
,
[
"label" => "Color 1",
"type" => "color",
"section" => COLOR_SECTION,
]
);
});
// example of utilisation of the color
add_filter("the_title", function ($t) {
$color1 = get_theme_mod(SETTING_COLOR1);
return "$t - $color1";
});https://stackoverflow.com/questions/51575130
复制相似问题