Skip to main content
Cookbook Content Menu Icons

Add Icons to Your Navigation Menu with AI

A fitting icon on each item of your menu, chosen from the icon sets you have on, shown to you first and set on your yes.

Difficulty Beginner
Time ~10 min

Prerequisites

A site connected to WPVibe running Menu Icons by Themeisle 0.13.27 or newer (tested on 0.13.27, free) on WordPress 6.9 or newer, with an administrator account, and a classic theme whose menus are set under Appearance, Menus.

The prompt
My site uses Menu Icons by Themeisle. Add a fitting icon to each item in my [header menu, or the menu's name]. [Optional: how you want them, for example icons after the text, a little bigger, only the top-level items, or only Font Awesome icons.]

1. Run discover_abilities with category menu-icons. If menu-icons/search-icons and menu-icons/set-item-icon are not both listed, stop and tell me to install or update the free Menu Icons by Themeisle plugin (0.13.27 or newer, on WordPress 6.9 or newer). If one answers that I am not allowed, tell me WPVibe must be connected as an administrator, then stop.
2. Run rest_api GET /wp/v2/themes?status=active. If is_block_theme is true, tell me that you can only set icons on classic menus (Appearance, Menus), and that links in the block editor's Navigation block get their icons in the editor instead (Menu Icons adds a Change Menu Icon button there), which you can't set or read; then ask before going on.
3. Find the menu: rest_api GET /wp/v2/menu-locations shows which menu id sits in each theme location (0 is none), and GET /wp/v2/menus?per_page=100 lists every menu with its id and name. If more than one menu could be the one I mean, ask me which.
4. List its items with rest_api GET /wp/v2/menu-items?menus=MENU_ID&per_page=100 (id, title, url, parent). For each item, read the icon it has now with run_wp_cli: post meta get ITEM_ID menu-icons --format=json (nothing back means no icon). Keep this as the before list.
5. Run menu-icons/search-icons with no input: it lists the icon sets that are turned on and the settings each supports. Only Dashicons is on unless someone ticked more under Icon Types in the Menu Icons Settings box on Appearance, Menus. Read the menu's own icon defaults, which Menu Icons uses when icons are picked by hand: run_wp_cli option get menu-icons --format=json, key menu_MENU_ID (if the option or that key is missing, there are none). The settings for each new icon are those defaults with what I asked for on top, and position before when neither says. Keep only the settings search-icons lists for the icon's type, leave out empty ones, use hide_label true when it is 1, and give sizes as numbers.
6. For each item that has no icon (leave the ones that have one alone unless I asked to replace them), run menu-icons/search-icons with a word for what the item means (home, cart, calendar, phone, email, info, location, user), with type set to one icon set for the whole menu so the icons match. If I asked for a set that isn't on, tell me to tick it under Icon Types in the Menu Icons Settings box on Appearance, Menus, and wait until I say it's done. Use type and id exactly as search-icons returns them. If nothing fits an item, leave it without an icon and say so.
7. Show me a table before changing anything: item, the icon you picked (set and id), and every setting you will pass (position before or after the text, font_size in em, where the set's default is 1.2, hide_label, vertical_align). Wait for my yes; menu changes show on the site at once.
8. Run menu-icons/set-item-icon for each item I approved, with item_id and icon set to type, id and the settings I asked for. Pass every setting shown in the table on each item, position included (without it the icon sits right against the text): on the site an item shows only the settings stored on it, even though the reply lists the menu's defaults too. Settings already stored on the item and left out stay as they are. If it answers menu_icons_disabled_for_menu, stop and tell me Menu Icons is turned off for that menu, by code on the site (the menu_icons_menu_settings filter, usually in the theme or a must-use plugin) or by a value written straight into the menu-icons option; there is no setting for it.
9. Finish with a list of each item, its old icon (or none) with its settings, and its new one, so I can spot-check the menu on the site while signed out (signed in, an administrator can see labels hidden by a menu setting that visitors don't get). To undo one, run menu-icons/set-item-icon with remove: true; if it had an icon before, set it again from the before list: its type; its icon value as id for a font set, or as attachment_id for image and svg; and only the settings search-icons lists for that type, skipping empty ones, with hide_label true if it was 1 (left out otherwise) and sizes as numbers. Setting the old icon without removing first keeps the new settings.
Already connected?

Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:

Run the “Add Icons to Your Navigation Menu with AI” recipe from the WPVibe cookbook on my connected site.

A menu with a small icon beside each item is quicker to scan: a house for Home, a calendar for Book, an envelope for Contact. Menu Icons can do it, but picking an icon for each item from hundreds, one item at a time in Appearance, Menus, is the kind of polish that never gets done.

The AI reads your menu and the icons it already has, searches the icon sets you have turned on for one that fits each item, and shows you its picks in a table before it changes anything. Menus have no drafts in WordPress, so nothing is set until you say yes, and it keeps a list of the old icons so any change can be undone.

Name the menu or where it sits (the header menu), and say how you want the icons if you care: before or after the text, a little bigger, only the top-level items. Items that already have an icon are left alone unless you ask. To check a menu’s icons without changing them, use this recipe; to build or reorder the menu itself, use this one.

Outcome

Each item of the menu has an icon that fits it, and you have a list of what changed and how to undo it.