wordpress如何在访问主页时更换主题?
修改wp-include/template-loader.php文件的底部,增加如下代码。
之后再访问主页时携带/?theme=主题名称的参数即可。
比如网址是www.xxx.com,主题名称是hello,(主题名称要看https://wordpress.org/themes/此地址的后缀)
那么实际访问时如下:www.xxx.com/?theme=hello,如此可以访问时修改默认主题。
if ( wp_using_themes() ) {
	// 修改部分
	if ($_GET['theme']) {
		switch_theme($_GET['theme']);
		sleep(0.5);
		wp_safe_redirect(site_url());
		exit;
	}
	// 修改部分结束
	$tag_templates = array(
		'is_embed'             => 'get_embed_template',
		'is_404'               => 'get_404_template',
		'is_search'            => 'get_search_template',
		'is_front_page'        => 'get_front_page_template',
		'is_home'              => 'get_home_template',
		'is_privacy_policy'    => 'get_privacy_policy_template',
		'is_post_type_archive' => 'get_post_type_archive_template',
		'is_tax'               => 'get_taxonomy_template',
		'is_attachment'        => 'get_attachment_template',
		'is_single'            => 'get_single_template',
		'is_page'              => 'get_page_template',
		'is_singular'          => 'get_singular_template',
		'is_category'          => 'get_category_template',
		'is_tag'               => 'get_tag_template',
		'is_author'            => 'get_author_template',
		'is_date'              => 'get_date_template',
		'is_archive'           => 'get_archive_template',
	);
	$template      = false;
苏公网安备
                32050902101537号