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

Is there a function to replace the active theme's stylesheet with a different one (not just adding a new one, but actually replacing the current one)?

I'm developing a plugin, and using shortcodes (eg: [design style="dark"]) and I want this shortcode to remove the current stylesheet and apply a new one, along with new HTML for the page as well.

In fact, I want this shortcode to completely replace all of the source code for that specific post.

Can anybody point me in the right direction? Thanks in advance.

share|improve this question
up vote 3 down vote accepted

Main stylesheet of theme is surprisingly rigid concept. It is usually semi-hardcoded in header.php before any meaningful hooks and is very hard to change by code and reliably.

Since your context is actually wider and includes markup as well, you are better of hijacking template entirely, see template_redirect action for starters.

share|improve this answer
This is exactly what I was looking for, thank you very much. Once again you've helped me out. :) – Jared Feb 21 '11 at 10:38

AFAIK there is no such function what you're asking for.

share|improve this answer

You might want to look at the Theme Switch and Preview plugin, uses shortcodes ([nkthemeswitch]).

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.