从“设置”>“阅读页面”切换主页/博客页面时,如何添加动作或触发功能?
类似的东西:
function on_home_blog_change($post){
//once the home page has switched to another page run this code
//Logic here
if ( $post->ID == get_option( 'page_for_posts' ) ) :
//blog
$page = 'blog';
elseif ( $post->ID == get_option( 'page_on_front' ) ) :
//home
$page ='home';
endif;
echo "<script>alert('". $page ." ". $old_ID ." switched with ". $new_ID ."')</script>";
}
add_action('transition_post_status', 'on_home_blog_change');
这是否有可能甚至是一种现成的方法?