Skip to main content
Cookbook Content Menu Icons

Use Your Own Image or Logo as a Menu Icon with AI

An image or SVG from your Media Library shown as the icon of a menu item, at the size you choose.

Difficulty Beginner
Time ~5 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. Image (or SVG) ticked under Icon Types in the Menu Icons Settings box, and the image uploaded to the Media Library.

The prompt
My site uses Menu Icons by Themeisle. Use the image [the image's title or file name] from my Media Library as the icon of the [item name] item in my [header menu, or the menu's name]. [Optional: the size, for example 1.5 times the text for an SVG, or the thumbnail size for an image.]

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. Find the item I named; if more than one matches, ask me which.
5. Find the image with rest_api GET /wp/v2/media?search=IMAGE_NAME&media_type=image&per_page=20, where IMAGE_NAME is the title or file name I gave. If more than one matches, show me their titles and ask which. Note its id and mime_type: image/svg+xml is the svg icon type, any other image is the image type.
6. 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. If the type you need isn't listed, stop and tell me to tick Image or SVG under Icon Types in the Menu Icons Settings box on Appearance, Menus. Use the settings that type lists: for image, image_size is one of its choices (thumbnail unless I asked otherwise); for svg, svg_width is in em (1 is the text's height, the default). An SVG file with its own width and height can show too tall on a theme without image styles: tell me to look at it signed out, and if it's stretched, to use an SVG with only a viewBox. An image icon shows at its pixel size, not the text's: read the image's width and height from GET /wp/v2/media/IMAGE_ID (media_details.sizes has each size; a size that isn't listed shows the image at its own width and height in media_details) and warn me if the size you'll use is more than about 40 pixels tall, since thumbnail is 150 pixels by default.
7. Show me the item, its current icon, the image (title, id, type, and its pixel size for an image) and every setting you will pass. Wait for my yes; menu changes show on the site at once.
8. Run menu-icons/set-item-icon with item_id and icon set to type, attachment_id and the settings. 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. If it answers menu_icons_invalid_attachment, the file doesn't match the type: an SVG needs svg, other images need image.
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 “Use Your Own Image or Logo as a Menu Icon with AI” recipe from the WPVibe cookbook on my connected site.

Sometimes the icon you need isn’t in any icon set: your own logo for the Home link, a brand that’s newer than the sets (TikTok, Threads), or a badge you designed for a sale. Menu Icons can show an image from your Media Library beside a menu item, but finding the right file and size takes a few rounds in Appearance, Menus.

The AI finds the image in your Media Library, checks it is an image or an SVG, matches it to the right kind of icon, and shows you the item, the file and the size before it sets anything. Nothing changes until you say yes, and it notes the item’s old icon so you can undo it.

Upload the image to your Media Library first, and tick Image (or SVG for an SVG file) under Icon Types in the Menu Icons Settings box on Appearance, Menus. An SVG is as wide as your menu’s text is tall, but an image shows at its pixel size: WordPress’s thumbnail size is 150 pixels by default, too big for most menus, so upload a small image (about the height of your menu text) or use an SVG. Name the menu item and the image’s title or file name.

Outcome

The menu item shows your image as its icon, and you have its old icon to undo with.