
在外观 – 主题 中点击启用主题后,立马跳转到主题设置页
在主题的functions.php中加入以下PHP代码即可:
方法一:
add_action( 'load-themes.php', 'Init_theme' );
function Init_theme(){
global $pagenow;
if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) {
// options-general.php 改成你的主题设置页面网址
wp_redirect( admin_url( 'options-general.php' ) );
exit;
}
}
方法二:
add_action('after_switch_theme', 'Init_theme');
function Init_theme($oldthemename){
global $pagenow;
if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) {
// options-general.php 改成你的主题设置页面网址
wp_redirect( admin_url( 'options-general.php' ) );
exit;
}
}
方法3
global $pagenow;
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) {
// admin.php?page=theme-settings-slug 改成你的主题设置页面网址
wp_redirect( admin_url( 'admin.php?page=theme-settings-slug' ) );
exit;
}
让插件启用后跳转到插件设置页面:
global $pagenow;
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'plugins.php' ) {
// options-general.php?page=plugin-page-slug 改成你的插件设置页面网址
wp_redirect( admin_url( 'options-general.php?page=plugin-page-slug' ) );
exit;
}
代码来自雅兮网

