How do I Redirect a WordPress Page?

I’m sure there is a more elegant way of achieving your desires, however this method does work. Just tested it.

/**
 * Redirect pages from array.
 *
 * @author Michael Ecklund
 * @author_url https://www.michaelbrentecklund.com/
 *
 * @return void
 */
function redirect_pages() {

    // Page from => Page to
    $redirect_pages = array(
        'wordpresspage' => '/wordpress-page'
    );

    // Check all required redirections.
    foreach( $redirect_pages as $page_from => $page_to ) {

        // Check the current page.
        if( is_page( $page_from ) ) {

            // Redirect to proper page.
            wp_redirect( site_url( $page_to ), 301 );
            exit;

        }

    }
}

In order to fire the redirection properly, you will need to add a page for “wordpresspage”, so that it can properly detect the current page and redirect to domain.com/wordpress-page/.

Add the action in order to trigger the hook.

add_action( 'template_redirect', 'redirect_pages' );