wp_nav_menu_container_allowedtags
Filter HookDescription
Filters the list of HTML tags that are valid for use as menu containers.Hook Information
| File Location |
wp-includes/nav-menu-template.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 189 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
string[]
|
$tags
|
The acceptable HTML tags for use as menu containers. Default is array containing 'div' and 'nav'. |
Usage Examples
Basic Usage
<?php
// Hook into wp_nav_menu_container_allowedtags
add_filter('wp_nav_menu_container_allowedtags', 'my_custom_filter', 10, 1);
function my_custom_filter($tags) {
// Your custom filtering logic here
return $tags;
}
Source Code Context
wp-includes/nav-menu-template.php:189
- How this hook is used in WordPress core
<?php
184 * @since 3.0.0
185 *
186 * @param string[] $tags The acceptable HTML tags for use as menu containers.
187 * Default is array containing 'div' and 'nav'.
188 */
189 $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
190
191 if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags, true ) ) {
192 $show_container = true;
193 $class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"';
194 $id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
PHP Documentation
<?php
/**
* Filters the list of HTML tags that are valid for use as menu containers.
*
* @since 3.0.0
*
* @param string[] $tags The acceptable HTML tags for use as menu containers.
* Default is array containing 'div' and 'nav'.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/nav-menu-template.php
Related Hooks
Related hooks will be displayed here in future updates.