12
votes
add_menu_page() with different name for first submenu item
Make the slug of the parent menu item and sub-menu same (first one item) as below
function actions_recent_bids_add_admin_page(){
add_menu_page(
'Recent Bids',
'Auction Reports'...
6
votes
Accepted
add_menu_page() for more than one user role
Let's take a look at Codex page for add_menu_page...
Third param is:
$capability (string) (Required) The capability required for this menu
to be displayed to the user.
And later on in Notes ...
6
votes
add_menu_page() with function inside a class
add_action must be inside the plugin class and should look like
add_action( 'admin_menu', array( $this, 'add_menu_items' ) );
Usually this line presents in the __construct() method.
4
votes
Accepted
Custom plugin settings link doesn't append current class to menu item when visited? Why?
I noticed your apwb_settings_page() function is adding the "Postal Pricing Settings" submenu using add_options_page(), and the documentation stated that: (bold formatting added by me)
This ...
4
votes
The seventh parameter passed to add_submenu_page()
I was able to track this down to the culprit function add_theme_page(). There
There was an additional parameter, per the codex for add_theme_page() that needed to be removed. Removing that seemed to ...
4
votes
Accepted
Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?
TL;DR: Yes, it's possible to add a Custom Dashboard Widget to a Custom Admin Menu Page.
Option-1: Without the dashboard like UI:
If all you want is just displaying the custom Widget data (without the ...
3
votes
add_submenu_page not working
I made the same mistake as the OP as it is not intuitive how to get this working. By reading the codex on Administration Menus, I discovered the answer.
The problem (for me, anyway) was to edit the $...
3
votes
Accepted
How is a widget supposed to reference what is added to custom submenu or addmenu fields?
The setting API, which its usage is being demonstrated in that code is meant to be use as a framework to create settings pages which result in update of values in options.
Widget settings are is a ...
3
votes
Adding an admin page - OOP approach not working
Working Example
class PluginSkeleton {
public function __construct(){
add_action('admin_menu',array($this,'pluginskeleton_menu'));
}
public function pluginskeleton_menu(){
...
3
votes
Hiding Admin Page While Keeping Menu Expanded
For your particular situation, where you need to have a menu registered, but not shown unless you click on it from a link on another page you can add a conditional check to see if you're on the ...
2
votes
Accepted
Insert & order custom post types in/as submenu
I found the answer. To make it short:
SOLUTION 1
If you want to simply add a custom post type to a menu item, go with solution number one (which involves creating a menu page with add_menu_pageand ...
2
votes
Wordpress custom plugin gives error
It seems that your function wstock_variation not exists or is created in PHP file not include in your plugin...
If you are using OOP, for example your code need to be like:
add_submenu_page( 'Elites-...
2
votes
How to use a WordPress' existing admin icon?
Apparently this code is working for me :
add_menu_page(
__( 'Test Book', 'testbook' ),
'Test Book',
'manage_options',
'includes/admin-options.php',
'test_book_menu_page',
'...
2
votes
WordPress Settings API Repeatable fields
It`s not the best solution but maybe it is helpful for you to create your own solution.
function display_ads_form_element()
{
// get the total number of "advertising codes" from the database
...
2
votes
Accepted
Finding the screen id of a page generated with add_menu_page
The function add_menu_page return the hook suffix that inform you about the current page.
A simple example to get the hook suffix.
public function add_menu_page() {
$page_hook_suffix = ...
1
vote
Accepted
Wordpress add page under admin submenu and retaining the active status of the parent submenu page in the menu
If I understand it correctly — you want the "Plans" sub-menu to be highlighted when on the "Add/edit plans" (pxmag-plans-edit) page, then you can do it like so:
Use the ...
1
vote
The seventh parameter passed to add_submenu_page()
This Notice can be triggered by several variations/wrappers of the function add_submenu_page.
as of WP v5.8
add_plugins_page
add_users_page
add_dashboard_page
add_posts_page
add_media_page
...
1
vote
Accepted
Plugin add_action and add_menu_page
The main difference is the location where the style (link) or script tag be in the source, or whether the resource is loaded in head or the footer.
With a add_menu_page()/add_submenu_page() callback ...
1
vote
Accepted
How to avoid creating first submenu page that is same as menu page?
You can set slug of a subpage to be the same as slug of parent page. For example:
public function onixion_admin_menu_option() {
add_menu_page('onixion',
'Onixion',
'manage_options'...
1
vote
Accepted
add page to main menu (frontend)
In order to know what are locations provided by theme for menus:
$locations = get_nav_menu_locations();
This command will return an associative array that has for keys the locations and for values ...
1
vote
meta box on new admin page
You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is ...
1
vote
Accepted
meta box on new admin page
You are trying to create a new admin page with add_pages_page(). Meta boxes are only for existing post types, not for admin pages. You need to create your fields like on a normal admin page.
You ...
1
vote
How can I create a new menu item that links to an archive of a custom post type?
After searching through the core Wordpress files, I found the necessary arguments. The key is setting menu-item-object to be the slug of your post type and the menu-item-type to be post_type_archive.
...
1
vote
Accepted
Show category and tag link as a submenu under custom post type submenu
WP Admin doesn't support 3 level menus in the side navigation. You can do this in WP Nav Menus on the frontend, but not with the main admin menu.
If you want to do this, you'll need to rebuilt the WP ...
1
vote
How to change menu page capability
It is possible, but only with add_menu_page().
/**
* Change admin menu after add menu page
*/
function wp_nh0afl5p_admin_menu_change() {
global $menu;
$page_slug = 'page-slug';
$...
1
vote
Accepted
Hiding Admin Page While Keeping Menu Expanded
The solution is based on the ideas provided by @Ian. Thanks.
add_action( 'admin_menu', 'add_the_menus' );
function add_the_menus() {
// Top level menu
add_menu_page ('Books', 'Books', '...
1
vote
Wp menu add page link as custom empty link
I think the problem you had is based on the custom post meta collision with qtransalte X.
1
vote
Wp menu add page link as custom empty link
finally i found where does the issue come from, it was a custom post metas that causing this problem, i don't know why but when i removed them, everything worked fine.
1
vote
Adding subdomain to home_url for "add_menu_page"
The way of your approach is arguably wrong. One shouldn't use add_menu_page for external links as that function isn't created for that purpose. Add menu page adds a page in the admin area with ...
1
vote
Add custom page link with anchor
I was searching for an answer for this but suddenly I got the idea and it works!
In the menu settings just add the anchor link just like an html link code <a href="#anchor" >titulo </a>
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
add-menu-page × 112admin-menu × 34
plugin-development × 20
menus × 19
add-submenu-page × 18
plugins × 16
wp-admin × 12
admin × 10
custom-post-types × 9
php × 9
theme-development × 6
capabilities × 6
metabox × 5
user-roles × 5
pages × 4
widgets × 4
dashboard × 4
settings-api × 4
sub-menu × 4
functions × 3
customization × 3
custom-taxonomy × 3
options × 3
custom-field × 2
forms × 2