Created
December 17, 2018 21:06
-
-
Save codeclinic/d432389e7d67f1a1fb73891feaa1d6fb to your computer and use it in GitHub Desktop.
WordPress Admin Menu: External link with Icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_custom_menu_item(){ | |
add_menu_page( 'Menu Item Title', 'Page Title', 'manage_options', 'page_slug', 'function', 'dashicons-icon', 1 ); | |
} | |
add_action( 'admin_menu', 'add_custom_menu_item' ); | |
function custom_menu_item_redirect() { | |
$menu_redirect = isset($_GET['page']) ? $_GET['page'] : false; | |
if($menu_redirect == 'page_slug' ) { | |
wp_safe_redirect( home_url('/my-page') ); | |
exit(); | |
} | |
} | |
add_action( 'admin_init', 'custom_menu_item_redirect', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment