Menu Custom Data Attributes

If you want to add a custom data attributes to the menu that’s generated by wp_nav_menu function. You can use the nav_menu_link_attributes filter to add the desired attributes to the <a> elements. function add_menu_atts( $atts, $item, $args ) { $atts[‘data-hover’] = $atts[‘title’]; // add data-hover attribute return $atts; } add_filter( ‘nav_menu_link_attributes’, ‘add_menu_atts’, 10, 3 );

Adding a custom taxonomy to “nav_menu_item”

This is not how you enable adding your taxonomy terms to menus. To do that you just set show_in_nav_menus to true when registering the taxonomy. You have it set to false. $args = array( ‘labels’ => $labels, ‘hierarchical’ => true, ‘public’ => true, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘show_in_nav_menus’ => true, // This ‘show_tagcloud’ … Read more

Remove a class from a using Walker

You don’t need to use the Walker to remove classes from nav menu items. There is a filter, nav_menu_css_class which can be used to modify the classes on menu items. Filters the CSS class(es) applied to a menu item’s list item element. This, for example, would remove the classes from all menu items: add_filter( ‘nav_menu_css_class’, … Read more

add another html tag after li element in wp_nav_menu

When using wp_nav_menu() you can exclude the <ul> tag by setting the items_wrap to only include the list items (%3$s), then you can add your own <li> before or after that, and wrap it with <ul> yourself: <ul class=”footer-links”> <li> <p>copyright C 2021</p> </li> <?php wp_nav_menu( array( ‘menu’ => ‘Footer Navigation Menu’, ‘theme_location’ => ‘top_nav_menu’, … Read more

Change text color dynamically in WordPress [closed]

If you inspect the text, you’ll see that your theme’s CSS is overriding your custom CSS. You have h2 { color: white; } but your theme has .widget h2 { color: inherit; } so “inherit” wins out. If you change your own CSS to .widget h2 { color: white; } it will override the theme. … Read more

Adding toggle-able element after menu item

You can easily add any HTML element to all menu items that have children by extending the Walker_Nav_Menu core class. The code below will add <i> icon element just after menu item </a> tag but you can of course change that if you need them inside or somewhere else by changing the $item_output variable. function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)