
简介
after_switch_theme 钩子主要是用来在切换主题时加载你想要实现的功能,并且只会执行一次。
语法
/*其中“function_name”是要调用的函数的名称*/ <?php add_action( 'after_switch_theme', 'function_name' ); ?>
用法
<?php
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;
}
};
?>


评论
0 访客 0