WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My theme has a custom.css file that I use to allow designer's to customize the it to their liking.

However, when clicking on "Appearance > Editor", the style.css file is loaded there by default.

Since I don't want custom edits done on this file, I'd like to minimize the chances that someone edits it by placing custom.css there instead.

Is this possible? Perhaps with the shiny new 3.2 codebase?

share|improve this question
up vote 0 down vote accepted

Unfortunately you can't control what files are loaded on that page...

But you can disable the editor page and provide the user with theme options that allow him to include his own CSS.

To deal with this I'm creating and activating a child theme automatically if possible:


    // fail, proably no write-access, use the parent theme...

    $parent = get_theme_data(TEMPLATEPATH.'/style.css');
    $name = get_stylesheet().'-extend';
    $destination = trailingslashit($GLOBALS['wp_filesystem']->wp_themes_dir()).$name;

    $style = "/*\n"
            ."Theme Name: {$parent['Name']} - Extend\n"
            ."Theme URI: {$parent['URI']}\n"
            ."Description: Automatically generated child theme of {$parent['Name']}. Please leave this one activated for proper customizations to {$parent['Name']}.\n"
            ."Version: 1.0\n"
            ."Author: {$parent['Author']}\n"
            ."Author URI: {$parent['AuthorURI']}\n"
            ."Template: ".get_template()."\n"
            ."/* You can safely edit this file, but keep the Template tag above unchanged! */\n";

      if($GLOBALS['wp_filesystem']->mkdir($destination, FS_CHMOD_DIR) && $GLOBALS['wp_filesystem']->put_contents($destination.'/style.css', $style, FS_CHMOD_FILE)){

        // copy screenshot and license.txt
        $GLOBALS['wp_filesystem']->copy(TEMPLATEPATH.'/screenshot.png', $destination.'/screenshot.png');
        $GLOBALS['wp_filesystem']->copy(TEMPLATEPATH.'/license.txt', $destination.'/license.txt');

        switch_theme(get_template(), $name);
        die(); // stop execution of the current page
        // fail again...
share|improve this answer

I would instead encourage your users to create Child Themes.

Among other advantages, if using Appearance -> Editor, the Child Theme's style.css will be the default file available for edit, rather than your (i.e. the Parent) Theme's.

share|improve this answer

After browsing the code a bit, it looks to me like WordPress doesn't provide an API hook to cleanly change the default file that gets loaded on that page.

As an alternative, you can (from within your theme's functons.php or in a plugin) remove certain menus and sub-menus. These blog posts should be useful if you decide to go that route (removing the Appearance -> Editor menu all together).

Personally, I'd be a little annoyed if I installed a theme and it took away functionality. (But I'm a developer). If you're worried that your users will monkey with style.css, they might not need access to the admin control panel at all.

share|improve this answer

Your Answer


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.