Skip to main content
deleted 5 characters in body
Source Link
Michael Ecklund
  • 6.8k
  • 13
  • 68
  • 110
/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @return void
 * @author Michael Ecklund
 *
 * @return void
 */
 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' ), 301 );
        exit;

    }

}

Fire the above function on the hook admin_init.Fire the above function on the hook admin_init.

add_action( 'admin_init', 'disallowed_admin_pages' );

Alternate syntax:

/**
 * 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;

    }

} );
/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 *
 * @return void
 */
 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' ), 301 );
        exit;

    }

}

Fire the above function on the hook 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
 *
 */
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;

    }

}

Fire the above function on the hook admin_init.

add_action( 'admin_init', 'disallowed_admin_pages' );

Alternate syntax:

/**
 * 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;

    }

} );
made code example more generic
Source Link
Michael Ecklund
  • 6.8k
  • 13
  • 68
  • 110
/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 * @access public
 *
  * @return void
 */
public 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', 'http'), 301 );
        exit; 

    } 

}

Fire the above function on the hook admin_init.

add_action('admin_init', array($this'admin_init', 'disallowed_admin_pages') );

/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 * @access public
 *
  * @return void
 */
public 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', 'http'), 301);
        exit;
    }
}

Fire the above function on the hook admin_init.

add_action('admin_init', array($this, 'disallowed_admin_pages'));

/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 *
 * @return void
 */
 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' ), 301 );
        exit; 

    } 

}

Fire the above function on the hook admin_init.

add_action( 'admin_init', 'disallowed_admin_pages' );

Source Link
Michael Ecklund
  • 6.8k
  • 13
  • 68
  • 110

/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 * @access public
 *
 * @return void
 */
public 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', 'http'), 301);
        exit;
    }
}

Fire the above function on the hook admin_init.

add_action('admin_init', array($this, 'disallowed_admin_pages'));