March 21, 201313 yr 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
March 22, 201313 yr 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