Can I set wordpress theme via code

126 Views Asked by At

I have been working on wordpress for a while. I know that we can manage themes via the admin panel and the selected theme and its configuration details are stored in the database.

Is there any way I can set the theme via my wordpress code?

1

There are 1 best solutions below

0
On BEST ANSWER

Have a look at the switch_theme function on the Codex

Description

Switches current theme to new template and stylesheet names. Accepts one argument: $stylesheet of the theme. ($stylesheet is the name of your folder slug. It's the same value that you'd use for a child theme, something like twentythirteen.) It also accepts an additional function signature of two arguments: $template then $stylesheet. This is for backwards compatibility.

Usage

<?php switch_theme( $stylesheet ) ?>