I wanted to integrate an icon font into a WordPress theme to use for sort of a “social” menu (links to the site owner’s Facebook/Twitter/etc profiles, represented by the icon of the respective service).
Adding the icon font isn’t the problem (drop in the font files, include the css and done) but adding the classes to the menu location? Turns out that’s easier than you might think :)
wp_nav_menu takes a number of parameters, 2 of which are
The icon font I was for this was the Symbol Set Social Regular. The icons are represented by a unicode string, a css class or a keyword (wrapped in a global css class).
wp_nav_menu(array( 'theme_location' => 'secondary', 'menu_class' => 'nav-menu', 'container_id' => 'top-right-menu', 'fallback_cb' => false, 'link_before' => '<i class="ss-icon">', 'link_after' => '</i>' ));
This wraps each menu item in the correct tags and it the text you put in the title field for that menu item matches the icon font (in this case the words “Facebook”, “Twitter”, “Instagram”, etc), it’ll render that menu item as an icon instead of text. Easy is pie. :)