Home  >  Article  >  Backend Development  >  Add sidebar menu to WordPress backend

Add sidebar menu to WordPress backend

不言
不言Original
2018-07-06 10:21:472252browse

This article mainly introduces the sidebar menu added in the WordPress backend, which has a certain reference value. Now I share it with you. Friends in need can refer to it.

add_action('admin_menu', 'register_custom_menu_page'); 
    function register_custom_menu_page() { 
        add_menu_page('自定义菜单标题', '测试菜单', 'administrator', 'show_ads/view.php', '', plugins_url('myplugin/images/icon.png'), 6); 
    }

In the folder where your plug-in is located Add a file as a new menu page, view.php

add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
  • $page_title: (string) (required) This parameter is the title of the submenu, which will be displayed in The title bar of the browser, which is empty by default;

  • $menu_title: (string) (required) The displayed menu name, which is empty by default;

  • $capability: (string) (required) User permissions, which defines which permissions users will see this submenu (please see the end of the article for permissions), the default is empty, refer to capability;

  • $menu_slug: (string) (required) The menu name displayed on the URl, the default is empty;

  • $function: the returned method name;

  • $icon_url: (string) (optional) The menu icon displayed, you can use plugin_dir_url(__FILE__), the width and height of the icon are 16 pixels;

  • $position: (integer) (optional) The position of the displayed menu. Commonly used positions, 4 or 59 or 99.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use wp_head() function in wordpress

The above is the detailed content of Add sidebar menu to WordPress backend. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn