Title: Theme filename variable?
Last modified: August 18, 2016

---

# Theme filename variable?

 *  [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/theme-filename-variable/)
 * I didn’t choose which version I’m using, because I’m using 3 of them…2.0.10, 
   2.1.3 and 2.2.
 * I’m currently trying to update the theme I released over a year ago – it’s sadly
   out of shape, and I’ve been updating it like crazy this weekend. There’s this*
   one* bitty thing that’s always driven me nuts, but I’ve let it go. I can continue
   to let it go, but I was wondering if there was a chance someone know how to fix
   this.
 * In my theme, I’ve made an “Options” page, where you can change the color/header
   of the theme. I’ve supplied stylesheets to this effect, and they are located 
   in a subfolder of the theme. Now, in my options page, I have a dropdown box that
   shows the current theme name, all nice and pretty. But if you want to switch 
   to another color, the dropdown contains the file name, rather than the name of
   the color change.
 * In other words, instead of seeing:
 * Alternate Styles: Orange Crush
    Blue Crush
 * you’re seeing:
 * Alternate Styles: Orange Crush
    blue_style.css
 * Now, I wanted to place the /* Template Name: Blue Crush */ in the top of the 
   CSS file, but it is, of course, not seeing it. So I was wondering, does anyone
   know what I could do to edit the following piece of code to get a nicely formatted
   name instead of the ugly filename to display?
 *     ```
       <?php
       global $wpdb;
       $name = get_option('orange_crush_style');
       $style_dir = @ dir(TEMPLATEPATH . '/styles');
   
       if ($style_dir) {
       while(($file = $style_dir->read()) !== false) {
   
       if (!preg_match('|^\.+$|', $file) && preg_match('@.(css)$@', $file))
   
       $styles[] = $file;
       }
       }
   
       if ($style_dir || $styles) {
   
       echo "<select name=\"alternate_style\" id=\"alternate_style\">\n";
   
       echo "<option value=\"$name\">";
   
       if($name) {
       echo $name;
       } else {
       echo "Orange Crush";
       }
   
       echo "</option>\n";
   
       $count = 0;
   
       if($styles) {
       foreach($styles as $style) {
   
       $count++;
   
       echo "<option value=\"$style\">$style</option>\n";
       }
       }
   
       echo "</select>\n";
       }
       ?>
       ```
   

The topic ‘Theme filename variable?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/theme-filename-variable/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
