Articles of add menu page

Plugin page and capabilities

i´am developing my own WP plugin with custom functions and i would like to show the new submenu in the standard admin panel for everyone, who logs in. My code: $capa = ‘administrator’ or ‘author’ or ‘visitor’; $this->pagehook = $page = add_menu_page(__(‘Myplugin’,’my_plugin’), __(‘Myplugin’,’my_plugin’),$capa, $this->page_id, array($this,’render’) ) As you can see, i defined 1 variable $capa, […]

Show category and tag link as a submenu under custom post type submenu

I have created a college management menu in admin, under that i have added some sub menus those submenus are of different post types. Those were working fine. But Category and tags are not showing as sub-sub-menu under custom post types College Management /* Main menu */ — Faculty /* Sub menu Custom post type […]

Hiding Admin Page While Keeping Menu Expanded

I am creating a custom admin section. I have the following code: // Top level menu add_menu_page(‘Books’, ‘Books’, ‘publish_posts’, ‘books’, ‘render_books_page’, ”, 17); // Adding this function to make the first submenu have a different name than the main menu // Details: https://wordpress.stackexchange.com/questions/66498/add-menu-page-with-different-name-for-first-submenu-item add_submenu_page(‘Books’, ‘Books’, ‘All Books’, ‘publish_posts’, ‘books’, ‘render_books_page’); // The Add Book menu […]

meta box on new admin page

I created a new page for the homepage settings of my theme using add_pages_page(). On that page I want to use wp.media to let the user select one or several images from the library (or upload new ones). I thought the way to go was meta boxes but I can’t get the box to display. […]

Seriously stuck with some custom meta box/plugin stuff

I’m working on a small plugin – part of it needs to add several meta boxes to all custom post types. I’ve tried looping through my array of custom port types in various ways but I keep getting errors that I’ve already called functions such as add_meta_box. The script below is my latest effort, it’s […]

How to add custom menu item on plugin activation?

When my plugin is activated, I would like to add a new menu item. Here is my code: class My_Plugin { function __construct() { register_activation_hook(__FILE__, array($this, ‘install’)); } function install() { add_action(‘admin_menu’, array($this, ‘add_menu_item’)); } public function add_menu_item() { add_menu_page(…); } } $my_plugin = new My_Plugin(); Unfortunately, it doesn’t work. I notice that install is […]

How to point “add_menu_page” to HTML file rather than PHP function

I added a new menu item for my plugin like this: add_menu_page( ‘Control Panel’, ‘My Plugin’, ‘manage_options’, ‘control-panel’, array($this, ‘control_panel_page’), plugins_url(‘/images/menu_icon.png’, __FILE__) ); public function control_panel_page() { // My HTML goes here } However, I feel uncomfortable with the fact that all my HTML resides in PHP function (control_panel_page). Is there an option/hack to point […]

How is a widget supposed to reference what is added to custom submenu or addmenu fields?

Stepping into advanced plugin development I’ve been following along with the Plugin Handbook but I did not see it mentioned how you’re to reference what has been added to the settings page. So for example, when you visit the sample settings page the menu created is: function wporg_options_page() { // add top level menu page […]

why add_menu_page use simple function as arg while add_meta_box a call back?

I was looking on WordPress function reference and find that add_menu_page takes simple function as arg while add_meta_box call it as call back. I am new to programming.. help me understand this

How can I highlight a top level dashboard menu item created for a custom taxonomy?

I’ve used add_menu_page() to create a top-level dashboard menu item for a custom taxonomy. This is due to some specific needs with respect to this plugin. The menu item works fine, but when you click it, the Posts menu opens. I’ve tried to hook the parent_file filter to change that and the best I’ve been […]