我是Wordpress和PHP的新手,我正在尝试为memberlite主题创建一个子主题。我想向自定义程序中添加自定义配色方案,但是我不知道如何注销父主题的customror.php或修改当前配色方案。 (我不确定哪种方法正确)。
在父主题functions.php中:
/* Customizer additions. */
require_once get_template_directory() . '/inc/customizer.php';
理想情况下,我想取消该文件的需求并添加自己的文件。
任何帮助将不胜感激。
答案 0 :(得分:0)
要添加带有颜色选择器的设置,请尝试以下代码:
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";
});