I am wondering how to conditionally load child themes? I have a site that is going to change with the seasons. The underlying architecture will remain the same, just different styles and a few minor changes. It seems that child themes is my best bet for this, vs using a bunch of conditional statements within my main theme and loading different stylesheets and what not.
What I am stuck on is how to properly load a specific child theme based on a date?
WordPress use an option to store the current active child theme. This option is named
'stylesheet'
.Using the filter
'pre_option_{$option_name}'
you can change every option getted by WP.So, in your case you should hook the
'pre_option_stylesheet'
filter, use some logic to retrieve current season and return the child theme you want.This workflow should be done in a plugin (loaded before theme and child theme), in this way you are sure it works.
Example plugin code: