
If you want to edit or add social icons to the end of WordPress Main menu, or any menu, you can use a filter to append what you want onto the end without having to hack with CSS, or overwrite your theme template files.
The following example appends a like button Icon to the end of the ‘secondary’ menu. You can wrap this in <li> tags as well if you want to preserve the formatting that has been applied to the menu – and float it right, or just use span or appropriate HTML tags that are suitable.
// Add content to end of main menu
add_filter('wp_nav_menu_items', 'menu_follow_icons', 10, 3);
function menu_follow_icons($menu, $args) {
$args = (array)$args;
if ( 'secondary' !== $args['theme_location'] )
return $menu;
$follow = '<li>Facebook Icon or any HTML content Goes Here</li>';
return $menu . $follow;
}
This function checks if you want to target a particular menu by the systems menu name. In this case, the ‘secondary’ menu was targeted within a genesis theme.
If you have any feedback or suggestions, I’d love to hear your thoughts.