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'...
Younas Ali's user avatar
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 ...
Krzysiek Dróżdż's user avatar
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.
KAGG Design's user avatar
  • 1,842
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 ...
Sally CJ's user avatar
  • 39.1k
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 ...
yannibmbr's user avatar
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 ...
Fayaz's user avatar
  • 8,909
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 $...
ban-geoengineering's user avatar
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 ...
Mark Kaplun's user avatar
  • 23.4k
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(){ ...
Amjad Ali's user avatar
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 ...
Ian's user avatar
  • 969
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 ...
Cerere's user avatar
  • 231
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-...
Santiago Cerro López's user avatar
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', '...
NJENGAH's user avatar
  • 379
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 ...
user141080's user avatar
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 = ...
bueltge's user avatar
  • 17.1k
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 ...
Sally CJ's user avatar
  • 39.1k
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 ...
alo Malbarez's user avatar
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 ...
Sally CJ's user avatar
  • 39.1k
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'...
Krzysiek Dróżdż's user avatar
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 ...
assistbss's user avatar
  • 153
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 ...
Scruffy Paws's user avatar
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 ...
LWS-Mo's user avatar
  • 1,522
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. ...
Michael Lynch's user avatar
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 ...
Tom J Nowell's user avatar
  • 59.2k
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'; $...
Lana Codes's user avatar
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', '...
Greeso's user avatar
  • 2,166
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.
prosti's user avatar
  • 4,283
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.
Amine Faiz's user avatar
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 ...
bravokeyl's user avatar
  • 3,349
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> ...
Fernando Baltazar's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible