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.

3 Answers 3


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.

  • This is exactly what I was looking for, thank you very much. Once again you've helped me out. :)
    – Jared
    Feb 21, 2011 at 10:38

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


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.