Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am creating my first plugin and so far it has gone well. It is very simple thing that calls the css file up and allows users to add shortcodes which will then create different colored backgrounds and CSS driven tables. Now rather than input thousands of CSS Blocks of code I thought it may be easier if people could input some of their own info so they could change things like the background color of the tables etc.

I came across this in the Codex...

function my_styles_method() {
        get_template_directory_uri() . '/css/custom_script.css'
        $color = get_theme_mod( 'my-custom-color' ); //E.g. #FF0000
        $custom_css = "
                        background: {$color};
        wp_add_inline_style( 'custom-style', $custom_css );
add_action( 'wp_enqueue_scripts', 'my_styles_method' );

Now I have altered it to match my parameters but what I am not getting is where does the user actually change this color? I am using shortcodes so I really don't understand this part of it. Like where would they actually input #FF0000 if they wanted a red background. I have looked high and low for actual samples of this code in use but have had no luck. I hope this makes sense it is my first post here :-)

share|improve this question
You will need to read up on the WP function get_theme_mod as this is where the "my-custom-color" value comes from, which the above code assigns to the $color variable. –  jdm2112 Jun 6 '14 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.