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.

Let's say theme 1.0 is installed with 30 files in it. Then two weeks later theme is upgraded to theme 2.0 which contains only 10 files. Do those older 20 files get automatically deleted after upgrade?

What I wanted to do is to place a file inside the theme directory, trough which the user can customize the theme. This file would be created after the theme is installed trough the theme settings. But if WP does delete files that do not exist in the official theme package, then this file would be deleted as well...

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Yes.

Find a theme that support Child Theme. Create a child theme so that your modification doesn't get deleted if you update the parent theme.

share|improve this answer
add comment

Two options:

Child Themes

Distribute a set theme that you plan to update. Auto-updates will replace this theme, so it should not be customized. Build a child theme on top of it to hold your customizations.

A great example is the Genesis Framework. Genesis is an advanced parent theme that lives in your /themes/ directory and is occasionally updated automatically by the team at StudioPress. Your live site, though, will use a child theme that inherits and customizes the behavior of Genesis.

Theme Options

If the customizations are minimal enough (i.e. a few lines of custom CSS) you can store them in the option table. You can build a theme settings page with buttons, checkboxes, and dropdowns for simple settings. Freeform CSS can be edited in a textbox and stored in the database as well.

These options will exist separately from the theme and will not be overwritten by theme updates.

Note: This isn't an optimal solution since it separates part of the theme definition and stores it in the database. Though it would accomplish some of what you're looking for, I'd strongly recommend the child theme route instead.

share|improve this answer
    
yes, I'm using the theme options to allow extra css rules to be added, but I want to do the same for php code (like a user functions.php file). Right now I store it in the options table like the CSS, and eval it, which is wrong in so many ways :) Storing the code in a php file and including it is a better solution... I know about child themes, but this is a theme I'm developing and plan to distribute it, so I can't force people to create child themes. I actually included a child theme inside one theme and people were still making changes to the parent theme code... –  onetrickpony Mar 18 '11 at 22:43
    
...maybe I should place the php file inside /wp-content/uploads/... –  onetrickpony Mar 18 '11 at 22:44
add comment

Looks like there's talk for the 3.2 roadmap of improving the upgrade system so that it only affects changed files, but thats a long way off and might only affect core upgrades. Plugin and theme upgrades do delete the entire folder and overwrite it.

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.