如何在WordPress中以编程方式设置主题()

我遇到的情况就像我在php网站中使用多个主题, 并且还集成了一个wordpress博客。
【如何在WordPress中以编程方式设置主题()】例如, 这是我的网站URL:http://example.com
我想通过传递查询参数来切换主题:

http://example.com?mytheme=red_theme http://example.com?mytheme=blue_theme etc.

目前, 我在WordPress中激活的主题就像blue_theme, 而我的WordPress博客URL是:
http://example.com/blog?mytheme=red_theme

例如:red_theme应该像预览一样显示。
否则, 如果我通过以下URL:
http://example.com/blog

然后, 应显示默认主题(blue_theme)。
我可以在核心PHP中对其进行调整, 但我不知道如何使用WordPress。
#1在WORDPRESS中, 你可以基于设备以编程方式设置主题, 例如移动设备上的不同主题和桌面上的不同主题。在默认主题的functions.php中编写以下代码
function use_mobile_theme() { // Chech device is mobile or not if(wp_is_mobile()){ return 'theme19388'; // set theme name here, which you want to open on mobile } else { return 'milano'; // set theme name here, which you want to open on other devices, like desktop } }add_filter( 'stylesheet', 'use_mobile_theme' ); add_filter( 'template', 'use_mobile_theme' );

    推荐阅读