/**
* Redirect admin pages.
*
* Redirect specific admin page to another specific admin page.
*
* @return void
* @author Michael Ecklund
*
*/
function disallowed_admin_pages() {
global $pagenow;
# Check current admin page.
if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'page' ) {
wp_redirect( admin_url( '/post-new.php?post_type=page' ) );
exit;
}
}
admin_init
ไฟฟังก์ชั่นดังกล่าวข้างต้นในเบ็ด
add_action( 'admin_init', 'disallowed_admin_pages' );
ไวยากรณ์สำรอง:
/**
* Redirect admin pages.
*
* Redirect specific admin page to another specific admin page.
*
* @return void
* @author Michael Ecklund
*
*/
add_action( 'admin_init', function () {
global $pagenow;
# Check current admin page.
if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'page' ) {
wp_redirect( admin_url( '/post-new.php?post_type=page' ) );
exit;
}
} );