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

If I have built a site using an existing theme (i.e. "Twenty-Ten"), but then modified it considerably and want to re-name it entirely, how would I go about doing this without breaking all the links? I know I can simply text-edit the style.css to change the name there, but I'm referring to the root all throughout the install:

<link rel='stylesheet' href='http://myWebsite.com/wp-content/themes/CURRENTTHEMENAME/styles/style.css" />

to ....

<link rel='stylesheet' href='http://myWebsite.com/wp-content/themes/NEWTHEMENAME/styles/style.css" />
share|improve this question
up vote 5 down vote accepted

You should never use <link> tags for stylesheets. Always use the proper API functions:

Better practice Example:

function wpse57423_register_stylesheets()
        array() // Use this array if you've deps that need to load before your stylesheet
        filemtime( get_stylesheet_directory()."/style.css" )
function wpse57423_enqueue_stylesheets()
    wp_enqueue_style( 'themes_main_stylesheet' );
// Add to public page
add_action( 'wp_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'wp_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );
// Add to login
add_action( 'login_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'login_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );
// Add to admin UI/backend
add_action( 'admin_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'admin_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );

Please note that the login page needs specific treatment. Refer to this answer if you need to handle it.

This allows to

  • enqueue/register styles only where you need them and don't load them everywhere
  • child themes the possibility to override your styles with adding a stylesheet with a) the same name in b) the same position in their folder
  • deregistering stylesheets in child themes
  • unhooking the functions
share|improve this answer
Sorry for my confusion, but where would I place this code? And would this code allow me to change the name of my theme? – mcranston18 Jul 4 '12 at 20:49
A) In your functions.php file OR a plugin B) Yes. The path is dynamic inside those functions. They use the dir structure constants of the WP filesystem, that you've set (or not set and therefore they're still default) inside your wp-config.php. – kaiser Jul 4 '12 at 21:49
Thanks for your help Kaiser. So I would: add the the code above into my functions.php file (does it matter where?), change my theme name within my style.css, and change the root-name of my theme (i.e. wp-content/themes/newNameForTheme), and I should be good to go? – mcranston18 Jul 5 '12 at 12:55

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.