# "In Menus" Column for Pages

> Adds a column to the Pages list showing which navigation menus link to each page, so editors know before renaming, moving or deleting a page that it appears in the site's menus.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin-columns, menus, pages
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-in-menus-column/

## Code

```php
$wpide_menu_map = null;

add_filter( 'manage_page_posts_columns', function ( $columns ) {
    $columns['wpide_in_menus'] = 'In menus';
    return $columns;
} );

add_action( 'manage_page_posts_custom_column', function ( $column, $post_id ) use ( &$wpide_menu_map ) {
    if ( 'wpide_in_menus' !== $column ) {
        return;
    }

    // Build the page => menus map once per screen.
    if ( null === $wpide_menu_map ) {
        $wpide_menu_map = array();
        foreach ( wp_get_nav_menus() as $menu ) {
            foreach ( (array) wp_get_nav_menu_items( $menu->term_id ) as $item ) {
                if ( 'post_type' === $item->type && 'page' === $item->object ) {
                    $wpide_menu_map[ (int) $item->object_id ][ $menu->term_id ] = $menu->name;
                }
            }
        }
    }

    $menus = $wpide_menu_map[ (int) $post_id ] ?? array();
    if ( ! $menus ) {
        echo '&ndash;';
        return;
    }
    $links = array();
    foreach ( $menus as $menu_id => $name ) {
        $links[] = current_user_can( 'edit_theme_options' )
            ? '<a href="' . esc_url( admin_url( 'nav-menus.php?action=edit&menu=' . (int) $menu_id ) ) . '">' . esc_html( $name ) . '</a>'
            : esc_html( $name );
    }
    echo implode( ', ', $links ); // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
}, 10, 2 );
```

## Notes

Covers classic menus (Appearance > Menus); links inside Navigation blocks of block themes are not listed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""In Menus" Column for Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
