Wordpress PHP Help
OK, I have a question that I think/hope is relatively easy to solve. To begin with, I'm not new to WP and have been using it for 3-4 years. My problem is I'm not great with PHP...just know a little.
I've got a Studiopress theme (not using the Genesis framework). The theme I'm using comes with 2 colour-styles, or layouts. I'm adding 10-14 additional colour schemes. So far so good. I know html/css very well so styling is easy for me.
However, since I don't know a lot about PHP, I'm trying to find the best way to include all the different stylesheets in the header.
Currently, since this theme only has 2 styles, it's using a simple if/elseif statement. No problem. However, since I'm adding so many styles, all I can think to do is have many elseif statements which I know isn't efficient coding.
Example:
Out of the box, the theme comes with this in the header....
<?php if(get_theme_mod('color_style') == 'Gray') { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } elseif(get_theme_mod('color_style') == 'Blue') { ?>
With all my new styles, I've got something like:
<?php if(get_theme_mod('color_style') == 'Gray') { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } elseif(get_theme_mod('color_style') == 'Blue') { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/styles/blue.css" type="text/css" media="screen" />
<?php } elseif(get_theme_mod('color_style') == 'Red') { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/styles/red.css" type="text/css" media="screen" />
etc.....
That's a lot of elseif statements if I have 10+ colour schemes. My initial (php newbie) thought is to create an include, ie <?php include('styles.php'); ?> and in styles.php have all my stylesheets. When someone selects a colour scheme in the theme options, it'll only pull the stylesheet of that particular colour scheme anyway (in the source code) but if I have up to 14 different styles, then in header.php it looks well...inefficient but, it's probably not a huge deal.
So, can anyone recommend how to more efficiently code the header? Is an include a good idea?
Ideally I'd just have something like:
<?php } elseif(get_theme_mod('color_style') == '<?php (get_option('color'))') { ?>
type="text/css" media="screen" />
or something like that where the selection would simply change within the one line of esleif but I don't know enough php to set this up in the functions.php (actually in the theme-options.php) page.
Does this make sense?
Any advice on how to SIMPLY and QUICKLY make this more efficient?
Thanks!!
Scott
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."