Can the wordpress theme folder be renamed any time freely and everything works fine after that ,

themes/oldthemename
themes/whatevernewname

or is it so that if you change the folder name that contains theme files – then the theme wont work any more because theme folder name is related to the theme files somehow …

5

This depends on how the theme was developed from the beginning. Theoretically, if everything was coded to standards you can rename the folder and nothing bad will happen.

When renaming the folder you are at risk of breaking code that asks specifically for files from the theme directory by name. WordPress offers a number of functions to help decouple the theme directory.

  • get_stylesheet_directory_uri
  • get_template_directory_uri
  • get_theme_root_uri
  • a couple of others (get_bloginfo)
  • and even the magic __FILE__ and __DIR__, along with dirname(), etc.

Using these function a theme can achieve loose coupling with what directory it resides in. Thus, if the theme that you want to rename the directory for has made good use of the above functions, then you should be fine.

Just in case, you can do a grep for the theme directory and see if it pops up in any javascript as a hardcoded path.

You will however have to reactivate it in your Appearance > Themes.

I just did this with twentyten and when you go to the admin you will see:

The active theme is broken. Reverting to the default theme.

Reactivate the theme and see if it works. twentyten does, twentyeleven does too.

The same goes for plugins, too.

wp_enqueue_style and wp_enqueue_script Codex pages state the following:

You should never hardcode URLs to local scripts, use Function Reference/plugins_url (for Plugins) and Function Reference/get_template_directory_uri (for Themes) to get a proper URL.

Leave a Reply

Your email address will not be published. Required fields are marked *