这都是Customizer API; 您将创建section, 添加一个setting 添加到节,然后添加controller 到设置。完成后,您将使用get_theme_mod()
例如,您可以将“公司名称”添加到Customizer,如下所示:
function mytheme_customize_register( $wp_customize ) {
$wp_customize->add_section( \'mytheme_company_section\' , array(
\'title\' => __( \'Additional Company Info\', \'mytheme\' ),
\'priority\' => 30,
));
$wp_customize->add_setting( \'mytheme_company-name\', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
\'mytheme_company_control\',
array(
\'label\' => __( \'Company Name\', \'mytheme\' ),
\'section\' => \'mytheme_company_section\',
\'settings\' => \'mytheme_company-name\',
\'priority\' => 1
)
)
);
// ..repeat ->add_setting() and ->add_control() for mytheme_company-division
}
add_action( \'customize_register\', \'mytheme_customize_register\' );
然后要在主题中显示这个动态值,您可以进入一个文件,如
header.php
或任何您想要的地方,并使用:
echo get_theme_mod( "mytheme_company-name" );