Which WordPress option stores the current active theme?

I always thought that the current theme is saved under the “template” option.

But looking inside the “secret” /wp-admin/options.php area, I see other related options.

In total, there are three:

  • template
  • stylesheet
  • current_theme

In my WP installation all those three have the exact same value. I would like to know what each of those options really does and which one is storing the actual current theme name that WP uses when loading templates.

It may seem useless as a question but the point is that I am “studying” the WP architecture, and this is one of the current confusion points of the road.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

All those options are actually pointing to the active theme, but the difference is the value stored in each option:

  • The options template and stylesheet both store the name of the active theme folder, e.g. twentytwentyone for the Twenty Twenty-One theme. But if you’re using a child theme, then stylesheet would be the name of the child theme folder, e.g. twentytwentyone-child.
  • current_theme on the other hand (is or seems like a deprecated option which) stores the name of the active theme on the site, e.g. Twenty Twenty-One.

    And this option is used by get_current_theme() (a deprecated function) and a deprecated option named mods_<theme name> (see get_theme_mods()).

    And note that I don’t have this option on my site (default install of WordPress 5.7), but if I had it, then the value would be the same as what wp_get_theme()->get( 'Name' ) returns.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x