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.

We created a theme that has a lot of changes in it. Now we want to enable that theme on our site in different colors, and a few images different:

enter image description here

What we're doing is duplicating the theme, and then making a few changes in the CSS, and change a few images. But it seems an overkill - to copy the all the theme files just to make so few changes. Moreover, if we ever have to change something functional in the theme, we'll have to go through all the duplications and apply it.

Is there a way to give users the option of changing colors & images, without duplicating the theme?

share|improve this question
2  
By users do you mean "website visitors" or "owners of different blogs on our site who choose a background for their blog"? You're totally right that you should not duplicate the theme, but how you go about it kind of depends on the answer to this question. –  Chris Carson Aug 7 '11 at 13:27
    
Thank you for your question. By users I mean "owners of different blogs on our site who choose a background for their blog" –  Lea Cohen Aug 8 '11 at 4:55
add comment

2 Answers

I would create a Theme Option for Color Scheme, then split out the color-scheme-specific CSS declarations into separate CSS files (e.g. blue.css, green.css, red.css, etc.).

Then, you simply enqueue the appropriate color-schme stylesheet, based on the Theme Option.

e.g.:

function mytheme_enqueue_color_scheme_stylesheet() {
    $theme_options = get_option( 'theme_mytheme_options' );
    $colorscheme = $theme_options['color_scheme'];
    $stylesheet = $colorscheme . '.css';
    $stylesheetsrc = get_template_directory_uri() . '/css/' . $stylesheet;
    wp_enqueue_style( 'colorscheme', $stylesheetsrc );
}
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_color_scheme_stylesheet' );
share|improve this answer
add comment
up vote 0 down vote accepted

We ended up using child themes, mainly because the site manager wanted to get a preview of the color change that would occur when changing CSS, and that was done best by the theme switching page, but also because it was easier...

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.