admin管理员组

文章数量:1122846

WordPress add_menu_page and add_submenu_page support adding custom page. The page created have url with a slug similar to wp-admin/admin.php?page=our-custom-page

How can create a admin page which will have a slug similar to wp-admin/admin.php/our-custom-page

I also want the pages to support inner routing similar to wp-admin/admin.php/our-custom-page

I know it can be done with server settings, I'm looking for way to created this from a theme/plugin.

The main goal is to create the custom admin page without any "?" of url params. The route is less important is long that it's inside wp-admin/

WordPress add_menu_page and add_submenu_page support adding custom page. The page created have url with a slug similar to wp-admin/admin.php?page=our-custom-page

How can create a admin page which will have a slug similar to wp-admin/admin.php/our-custom-page

I also want the pages to support inner routing similar to wp-admin/admin.php/our-custom-page

I know it can be done with server settings, I'm looking for way to created this from a theme/plugin.

The main goal is to create the custom admin page without any "?" of url params. The route is less important is long that it's inside wp-admin/

Share Improve this question asked Apr 5, 2020 at 22:21 BenBBenB 79510 silver badges24 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

How can create a admin page which will have a slug similar to wp-admin/admin.php/our-custom-page

You can't, this is not possible in WP Admin

Unlike the frontend, WP Admin does not support pretty URLs, and has no rewrite rules system to plug into. What you're already using is the closest available solution.

This answer may be late for too long, but I just want to share my solution with future readers.

tldr;

# Inside your .htaccess

<IfModule mod_rewrite.c>
...
...

RewriteRule ^index\.php$ - [L]

# Add This Line To your .htaccess file
RewriteRule ^wp-admin/our-custom-page/?$ wp-admin/admin.php?page=our-custom-page [L]
...
...
</IfModule>

Let me know if you have any questions :)

本文标签: pluginsAdd custom WordPress admin page with pretty url via code