WordPress provides some default options in the Theme Customizer, and we can also add our own. Let's add the option for users to tweak the color of links.
functions.php
, add the following code between the curly braces in the function you just defined:// SETTINGS $wp_customize->add_setting( 'content_link_color', array( 'default' => '#088fff', 'transport' => 'refresh', ) ); // CONTROLS $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'content_link_color', array( 'label' => 'Content Link Color', 'section' => 'colors', ) ) );
functions.php
file.We added a function to enable users to change the link colors in their site using the Theme Customizer. This is the most complex piece of PHP code we've added yet so let's have a look at how it works:
$wp_customize->add_setting
function:new
WP_Customize_Color_Control
function:content_link_color
is the ID for our setting that tells WordPress that this control will amend that settinglabel
value is what WordPress will display in the Theme Customizer screensection
is the section within that screen in which WordPress will place our control, in this case, colors
Let's see what our Theme Customizer looks like now:
Any changes the user makes won't actually have any effect yet, because we haven't told WordPress to alter the CSS based on their modifications.