Audit your menus for links that go nowhere

MenusBeginner~10 min

Before you start

A connected site whose bound user holds the edit-theme-options capability, since the menu reads are gated behind it. No menu write abilities are needed, and none are used.

Navigation rots quietly. A page gets trashed, a post goes back to draft while somebody rewrites it, a link gets typed with a stray character, and the menu item survives all of it. Nothing warns you, because WordPress keeps menu items and content in separate places and never checks one against the other. The first person to notice is usually a visitor landing on a 404.

This prompt does that check for you. It reads every menu, reads your real content, compares the two, and tells you which links point at nothing. It writes nothing and touches no menu.

The prompt
Audit the navigation menus on this site for links that go nowhere. Read only,
change nothing.
Start by listing every menu with its name and how many items it has. Then read
the items in each one, showing me the label, the URL, and what each item
actually links to.
Now build the other side of the comparison: list my pages and posts, including
anything sitting in drafts or in the trash, so you have a real inventory to
check against. Cross-reference the two and flag every menu item whose target
is missing, unpublished, or trashed. For each one, give me the menu it lives
in, the label a visitor sees, and what it is pointing at.
List any custom URLs separately, since you cannot verify where those actually
lead, and say plainly that they need a manual check. Report menu by menu with
the worst offenders first, and recommend nothing until I ask.

Why this is safe to run

All four abilities here are reads. Listing menus, reading a menu’s items, listing pages, and listing posts each report what is already there and cannot add, rename, or remove a link. The menu write abilities, the ones that could actually change your navigation, are a separate set with separate switches, and this recipe never asks for them. So the output is a list of suspects, and every fix stays a decision you make on your own.

Two honest notes on the method. There is no built-in broken-menu-links report in WordPress to read, so the answer is derived: the agent compares your menu items against the pages and posts it can list, and anything with no match is flagged. That comparison is only as complete as the inventory behind it, so scope the content list generously when you run it. And no read here fetches a URL, which means a menu item pointing at an external site cannot be tested for a 404 at all. Those come back on their own list, labeled as unverified, rather than being passed off as fine.

One access note. The menu reads are gated behind the edit-theme-options capability, so the user you bound the agent to needs it or the audit will come back denied rather than empty. Every call runs against that user’s real capability and lands in the Activity Log.

Already connected? Skip the paste. Ask your agent for the “audit your menus for links that go nowhere” recipe, or just ask which of your navigation links point at missing pages, and it runs the same reads against your own site.

How it works

  1. List every navigation menu with its name and item count.
  2. Read the items in each menu, with each label, its URL, and what it links to.
  3. List your pages and posts so there is a real inventory to check against.
  4. Match each menu item's target to that inventory and flag anything that is missing, drafted, or trashed.
  5. Separate out the custom URLs, which point outside your content and need a manual check.
  6. Report the findings menu by menu, worst first.

Questions

Does this change or remove any menu items?
No. Every ability behind it is a read, and the menu write abilities are not part of this recipe at all. It hands you a list of suspect items with their menu, label, and target. Fixing or removing one is a separate decision you make and act on yourself.
Will it catch a broken link to an external site?
No, and that is the honest limit here. None of these reads fetches a URL, so a menu item pointing at somebody else's site cannot be checked for a 404. The prompt lists those custom URLs separately so you know which ones it could not verify, rather than quietly passing them as healthy.
Is there a built-in report of broken menu links this reads?
There is not. WordPress stores menu items and content as separate things and never reconciles them, so a page moving to the trash leaves its menu item sitting there. This recipe derives the answer by cross-referencing your menu items against your actual pages and posts. It is a comparison the agent assembles, not a screen you could open.