Using WordPress ‘after_menu_locations_table’ PHP action

The after_menu_locations_table WordPress PHP action is used to add custom content or functionality after the menu locations table is displayed in the WordPress admin panel.

Usage

To use the after_menu_locations_table action, add the following code to your theme’s functions.php file or a custom plugin:

add_action('after_menu_locations_table', 'your_custom_function');

function your_custom_function() {
    // Your custom code here
}

Parameters

  • There are no parameters for this action.

More information

See WordPress Developer Resources: after_menu_locations_table

Examples

Add a custom message after the menu locations table

Display a custom message to inform users about a new menu location:

add_action('after_menu_locations_table', 'add_custom_message');

function add_custom_message() {
    echo '<p><strong>Note:</strong> A new menu location has been added for the footer section.</p>';
}

Add a button to refresh menu locations

Add a button to refresh menu locations, useful when new locations are added by a plugin or theme:

add_action('after_menu_locations_table', 'add_refresh_button');

function add_refresh_button() {
    echo '<a href="#" class="button">Refresh Menu Locations</a>';
}

Display custom menu location information

Show additional information for a specific menu location:

add_action('after_menu_locations_table', 'display_custom_location_info');

function display_custom_location_info() {
    echo '<p>Custom menu location "Top Bar" supports up to 3 items.</p>';
}

Add a custom table after the menu locations table

Display a table with custom menu-related data after the menu locations table:

add_action('after_menu_locations_table', 'add_custom_table');

function add_custom_table() {
    echo '<table class="widefat"><thead><tr><th>Menu Name</th><th>Custom Data</th></tr></thead><tbody><tr><td>Main Menu</td><td>Example data</td></tr></tbody></table>';
}

Add a form to manage custom menu settings

Add a form to allow users to manage settings related to custom menus:

add_action('after_menu_locations_table', 'add_custom_menu_settings_form');

function add_custom_menu_settings_form() {
    echo '<form method="post" action="options.php">';
    echo '<h3>Custom Menu Settings</h3>';
    echo '<label for="custom_menu_setting">Enable custom menu feature:</label>';
    echo '<input type="checkbox" name="custom_menu_setting" id="custom_menu_setting">';
    echo '<input type="submit" class="button button-primary" value="Save Changes">';
    echo '</form>';
}