WordPress filter hook · part of WordPress core

wp_nav_menu_container_allowedtags

A WordPress core filter that 11 plugins also fire themselves, running on 122K+ sites between them.

“Filters the allowed tags for the wp_nav_menu_container.”

How to use wp_nav_menu_container_allowedtags

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'wp_nav_menu_container_allowedtags', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from BuddyPress's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

11 plugins that fire wp_nav_menu_container_allowedtags

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. BuddyPress icon BuddyPress90,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) ) bp-core/bp-core-template.php:3643
  2. Essential Widgets icon Essential Widgets10,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) includes/widgets/class-ew-menus.php:80
  3. Advanced Custom Fields: Nav Menu Field icon Advanced Custom Fields: Nav Menu Field8,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) nav-menu-v4.php:157
  4. EasyMega icon EasyMega5,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) inc/menu.php:126
  5. Groovy Menu Plugin (Free) icon Groovy Menu Plugin (Free)4,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) includes/modules/core/inc/GroovyMenuUtils.php:2022
  6. ACF Nav Menu Field icon ACF Nav Menu Field3,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) includes/field/nav-menu.php:84
  7. Widgets Reloaded icon Widgets Reloaded1,000+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) inc/widgets/class-nav-menu.php:114
  8. MAS Elementor icon MAS Elementor800+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) classes/class-wp-bootstrap-navwalker.php:396
  9. Voce Cached Nav icon Voce Cached Nav100+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) voce-cached-nav.php:242
  10. Line Style Menus icon Line Style Menus10+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) line-style-menu.php:223
  11. ShopCode Menu Horizontal WooCommerce icon ShopCode Menu Horizontal WooCommerce10+ installs apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ) shopcode-menu-horizontal-woocommerce.php:115

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.