代码输出所有内容(样式标记、div类、括号等),但我选择的实际颜色除外。如何显示实际输出(primary\\u color)?
注册自定义颜色选择器:
// WP THEME CUSTOMIZER: COLORS
$colors = array();
$colors[] = array(
\'slug\'=>\'primary_color\',
\'default\' => \'#88C34B\',
\'label\' => __(\'Primary Color\', \'Ari\')
);
调用颜色:
//// WP THEME CUSTOMIZER: GENERATE CSS
function mytheme_customize_css()
{
?>
<style type="text/css">
html, body, .container { color:<?php echo get_theme_mod(\'primary_color\'); ?>; }
</style>
<?php
}
add_action( \'wp_head\', \'mytheme_customize_css\');
完整代码可在此处找到:
//// WP THEME CUSTOMIZER: GENERATE CSS
function mytheme_customize_css()
{
?>
<style type="text/css">
html, body, .container { color:<?php echo get_theme_mod(\'primary_color\'); ?>; }
</style>
<?php
}
add_action( \'wp_head\', \'mytheme_customize_css\');
// WP THEME CUSTOMIZER: COLORS
$colors = array();
$colors[] = array(
\'slug\'=>\'primary_color\',
\'default\' => \'#88C34B\',
\'label\' => __(\'Primary Color\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'secondary_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Secondary Color\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'heading_bg_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Heading Background\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'heading_font_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Heading Font\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'heading_links_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Heading Links\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'heading_links_hover_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Heading Links Hover\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'headings_color\',
\'default\' => \'#333333\',
\'label\' => __(\'Headings Color\', \'Ari\')
);
$colors[] = array(
\'slug\'=>\'background_color\',
\'default\' => \'#FFFFFF\',
\'label\' => __(\'Background Color\', \'Ari\')
);
foreach( $colors as $color ) {
// SETTINGS
$wp_customize->add_setting(
$color[\'slug\'], array(
\'default\' => $color[\'default\'],
\'type\' => \'option\',
\'capability\' =>
\'edit_theme_options\'
)
);
// CONTROLS
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
$color[\'slug\'],
array(\'label\' => $color[\'label\'],
\'section\' => \'colors\',
\'settings\' => $color[\'slug\'])
)
);
}
// WP THEME CUSTOMIZER: LAST LINE
}
add_action( \'customize_register\', \'wptuts_theme_customizer\', 11 );