Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

WP Theme Customization API

Featured Replies

Hey all,

 

Does anyone know of any good WP Theme Customization API tutorials that get in depth on how to add options/settings etc. I have found some but they dont really go into great depth, just showing the possibilities I have found one and copied the code directly and still no extra options are appearing.

 

Any directions to this would be great :D

 

 

  • Author

I have managed to get the options to appear in the theme customization bar but I cant get the color to be inputed into the style tag using the get_theme_mod function. When I look at the source its empty - could someone look at the code and see why its not working?

 

 

<?php
function themename_customize_register($wp_customize){
$theme = wp_get_theme();
$wp_customize->add_section('colouring_section', array(
'title' => __('Color Scheme', $theme->name),
'priority' => 10,
));
// =============================
// = Color Picker =
// =============================
$wp_customize->add_setting('square_setting[text_color]', array(
'default' => 'red',
'capability' => 'edit_theme_options',
'type' => 'option',
'transform' => 'refresh'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'text_color', array(
'label' => __('Link Color', $theme->name),
'section' => 'colouring_section',
'settings' => 'square_setting[text_color]',
)));
}
add_action('customize_register', 'themename_customize_register');
function mytheme_customize_css()
{
?>
<style type="text/css">
p { color:<?php echo get_theme_mod('text_color'); ?>; }
</style>
<?php
}
add_action( 'wp_head', 'mytheme_customize_css');

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.