简体   繁体   中英

how to give my WordPress menu page custom link

I have created a menu page using add_menu_page() and now page link is admin.php?page=xxxx ,but I am using this page to show notifications using add_action('admin_notices', 'any_name'); and in this any_name function I used if ( $pagenow == '' ) {} to specify the page where the notification should appear , and 'pagenow' dont accept link like admin.php?page=xxxx ,I cant figure out how to do it .

$pagenow would have a value of admin.php , not admin.php?page=xxxx .

So, you could check if you're on a specific page like this:

<?php
if ( 'admin.php' === $pagenow && 'xxxx' === $_GET['page'] ) {
  // Display the admin notice
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM