Title: How to change theme programmatically
Last modified: August 16, 2021

---

# How to change theme programmatically

 *  [paweluz](https://wordpress.org/support/users/paweluz/)
 * (@paweluz)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/how-to-change-theme-programatically/)
 * Hi,
 * This may look like a very easy question, but somehow I was not able to find any
   info anywhere. I have a wordpress site, with two themes: dark and light. I have
   a toggle buton that changes this – it is done by the theme implementation itself.
 * I would like to change the Enlighter theme programmatically, when I press dark/
   light page theme button change. All I was able to find out that I can change 
   the theme settings in wordpress settings in general, but I do not wat that – 
   I want it to be dynamic, depending on the toggle button position. All I was able
   to find out is this piece of code:
 *     ```
       EnlighterJS.init('pre', 'code', {
                       language : 'javascript',
                       theme: 'godzilla',
                       indent : 2
               });
       ```
   
 * But when I add it the firebug style of editor do not change at all. How can I
   do this ?
 * cheers
    -  This topic was modified 4 years, 8 months ago by [paweluz](https://wordpress.org/support/users/paweluz/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Andi Dittrich](https://wordpress.org/support/users/andi-dittrich/)
 * (@andi-dittrich)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/how-to-change-theme-programatically/#post-14772722)
 * there are two possible options to achieve such behaviour:
 * 1. (recommend) create your own EnlighterJS theme and wrap everything in a css
   class which is added to your body and represents the current page style e.g. `
   theme-dark` and `theme-light`
 * 2. (not recommended) change the theme class of EnlighterJS generated codeblocks
   to your desired theme using javascript (take a look into the generated DOM, it’s`
   enlighter-t-<name>`

Viewing 1 replies (of 1 total)

The topic ‘How to change theme programmatically’ is closed to new replies.

 * ![](https://ps.w.org/enlighter/assets/icon-256x256.png?rev=1215872)
 * [Enlighter - Customizable Syntax Highlighter](https://wordpress.org/plugins/enlighter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/enlighter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/enlighter/)
 * [Active Topics](https://wordpress.org/support/plugin/enlighter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/enlighter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/enlighter/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Andi Dittrich](https://wordpress.org/support/users/andi-dittrich/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/how-to-change-theme-programatically/#post-14772722)
 * Status: not resolved