[英]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');
我已经使用add_menu_page()
创建了一个菜单页面,现在页面链接是 admin.php?page=xxxx ,但我使用这个页面来显示使用add_action('admin_notices', 'any_name');
通知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 .在这个 any_name 函数中,我使用if ( $pagenow == '' ) {}
来指定应该出现通知的页面,并且“pagenow”不接受像 admin.php?page=xxxx 这样的链接,我不知道如何做吧。
$pagenow
would have a value of admin.php
, not admin.php?page=xxxx
. $pagenow
的值为admin.php
,而不是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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.