admin管理员组文章数量:1328037
I'm trying to add a sub page under users in admin panel and everything works fine but I have a little problem when clicking on the created page the url changes and refer to my page as query string not new php file
URL : http://localhost/wordpress/wp-admin/users.php?page=filtered.php
and I want : http://localhost/wordpress/wp-admin/filtered.php
is there any way to do so ?
function wporg_options_page(){
add_submenu_page(
'users.php',
'Filtered Users',
'Filtered Users',
'manage_options',
'filtered.php',
'filtered_user_page_html',
1 );
}
add_action('admin_menu', 'wporg_options_page');
I'm trying to add a sub page under users in admin panel and everything works fine but I have a little problem when clicking on the created page the url changes and refer to my page as query string not new php file
URL : http://localhost/wordpress/wp-admin/users.php?page=filtered.php
and I want : http://localhost/wordpress/wp-admin/filtered.php
is there any way to do so ?
function wporg_options_page(){
add_submenu_page(
'users.php',
'Filtered Users',
'Filtered Users',
'manage_options',
'filtered.php',
'filtered_user_page_html',
1 );
}
add_action('admin_menu', 'wporg_options_page');
Share
Improve this question
asked Jul 22, 2020 at 13:40
Islam Hanafi MahmoudIslam Hanafi Mahmoud
1616 bronze badges
4
|
1 Answer
Reset to default 0As per the requirement in the comments, one way to do that rewrite is with .htaccess. This may be possible with Wordpress rewrite functions too, but I find .htaccess easier as there are some constraints with the Wordpress functions.
If your Wordpress installation is at http://localhost/wordpress
then your .htaccess should be in the wordpress
directory.
Add this to the top of it to do the rewrite you want:
RewriteEngine On
RewriteRule ^wp-admin/filtered.php(/.*)$ wp-admin/users.php?page=filtered.php$1 [NC,L]
Note:
- This must be added in your root
.htacess
file above the start of the Wordpress Rules - This will not change the URL in the browser. You can add a redirect if you want it to redirect with e.g.
[R=301,NC,L]
- This is untested but should do what you want or get you close to what you need.
- As per the comments this is only the URL that you can use to access this page, this won't automatically change any URL's that get rendered in Wordpress
本文标签: wp adminHow to change the URL of sub menu page
版权声明:本文标题:wp admin - How to change the URL of sub menu page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742239799a2438747.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
http://localhost/wordpress/wp-admin/users.php?page=filtered.php
And you want that to be accessed with this URL: localhost/wordpress/wp-admin/filtered.php you could do that with rewrite rules. I'm not sure if that's what you want though as perhaps you're trying to have the menu item URL generated differently? – mozboz Commented Jul 22, 2020 at 19:56