2

I tried to add arrow down when the menu has a sub-menus. But the down arrow not showing up. Please help me.

Here's the link: http://bit.ly/1UH4FlT

Currently using this script that I found somewhere.

function add_menu_parent_class( $items ) {
 $parents = array();
foreach ( $items as $item ) {
 if ( $item->current_page_ancestor && $item-> current_page_ancestor> 0 ) {
  $parents[] = $item->current_page_ancestor;
 }
}
foreach ( $items as $item ) {
 if ( in_array( $item->ID, $parents ) ) {
  $item->classes[] = 'menu-item-has-children';
 }
} 
 return $items;
}
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );

And I added this css

#site-navigation .menu > ul > li.menu-item-has-children > a:before {
color: #fff;
content: "\f107";
font-family:FontAwesome;
font-size: 10px;
vertical-align: 1px;
}
#site-navigation .menu > ul > li > li.menu-item-has-children > a:after {
color: #222;
content: ""\f105"";
font-family:FontAwesome;
font-size: 10px;
vertical-align: 1px;
}

3 Answers 3

2

Add below code

#site-navigation .menu > ul > li.menu-item-has-children > a::after {
content: '\f107';
font-family: FontAwesome;
font-size: 10px;
margin-left: 10px;
vertical-align: 1px;
}


#site-navigation .menu > ul > li > ul > li.menu-item-has-children > a::after {
color: rgb(34, 34, 34);
content: '\f105';
font-family: FontAwesome;
font-size: 10px;
vertical-align: 1px;
float: right;
}

Add 3rd level navigation. If you face any issues, reply.

1
  • still the arrow down is not showing up. Do you think there's some issue in my function? Commented Aug 17, 2015 at 1:43
1

You Add Two time ("") Quote in you css see below

Replace

content: ""\f105"";

To

content: "\f105";

And Check Again

1
  • still arrow down no displaying Commented Aug 17, 2015 at 1:43
0

you can add a arrow next to the menu label with the free plugin "Menu Icons". go in "extensions" -> "add new" and search "Menu Icons"

after activating this plugin, go to the menu editor and at each menu element you can choose a icon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.