How to redirect one admin URL to another when admin page URL has “/admin.php?page=” in it?


The following code (from here, middle section chopped out) allows me to redirect users who land on a certain page in the WP admin to another admin page…

function admin_redirects() {
    global $pagenow;

    /* Redirect Customizer to Theme options */
    if($pagenow == 'customize.php'){
        wp_redirect(admin_url('/admin.php?page=theme_options', 'http'), 301);


add_action('admin_init', 'admin_redirects');

It works great…for some pages. The problem is I cannot get redirects to work for pages originating with a URL structure such as “admin.php?page=example-options.” The example-options string is just a plugin I was working on, but I think you get the idea. I have tried a lot of variations and other things at this point, but nothing is working. Am I missing something?

user2461674 3 months 0 Answers 15 views 0

Leave an answer