UC
Size: a a a
UC
ВБ
UC
UC
UC
// Remove the <div> surrounding the dynamic navigation to cleanup markup
function my_wp_nav_menu_args($args = '')
{
$args['container'] = false;
return $args;
}
// Remove Injected classes, ID's and Page ID's from Navigation <li> items
function my_css_attributes_filter($var)
{
return is_array($var) ? array() : '';
}
add_filter('wp_nav_menu_args', 'my_wp_nav_menu_args'); // Remove surrounding <div> from WP Navigation
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected classes
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected ID
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> Page ID's
ВБ
ВБ
ВБ
UC
UC
UC
UC
UC
ВБ
function theme_navigation() {
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus([
'header_menu' => __( 'Верхнее меню', 'custom-theme' ),
]);
}
}
add_action('init', 'theme_navigation');
if ( ! function_exists( 'header_menu' ) ) {
function header_menu() {
wp_nav_menu(array(
'theme_location' => 'header_menu',
'menu_class' => 'horizontal-menu',
'menu_id' => '',
'container' => '',
'container_class' => '',
'container_id' => '',
'depth' => 0,
'fallback_cb' => '__return_empty_string',
'items_wrap' => '<ul class="%2$s">%3$s</ul>'
));
}
}
ВЫВОД:<?php if ( function_exists( 'header_menu' ) ) : ?>
<nav class="top-header__menu"><?php header_menu(); ?></nav>
<?php endif; ?>
ВБ
ВБ
ВБ
UC
ВБ
UC