• I want to rearrange the submenus in the backend.

    Example: I have the following menu structure:

    • Custom Post Type 1
      • Submenu 1.1
      • Submenu 1.2
      • Submenu 1.3
    • Custom Post Type 2
      • Submenu 2.1
      • Submenu 2.2
      • Submenu 2.3

    I want to move Submenu 2.3 to Custom Post Type 1.

    How can I do this without using a plugin?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The global array $submenu can be manipulated to alter what items go where. Find the entry you want to move. Move it to under the appropriate post type entry, removing it from its initial position. Mind the index number assigned to each element (5, 10, 15, etc.) You may alter this number as needed so the item occurs numerically in the right position. This needs to be done late enough so all the menu items have been established, but not so late that the menu has already been output. I suggest trying the “admin_init” action hook first.

    You’ll want to dump out the entire array so you can understand how it’s organized and to learn what data under which array keys need to be altered.

    This code to do so will need to go somewhere safe, which typically means a custom plugin. When you say “without using a plugin”, I assume you mean without an existing plugin that’s available to all. The only other possibility besides a custom plugin is your theme’s functions.php. Only alter your theme’s files if it’s not subject to periodic updates.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.