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
}