Pinegrow Community Support Forum

Adding FontAwesome icons to menu items


#1

This is in reply to a question posted by @JakesMaps on Pinegrow’s Slack #starter-theme about adding icons to Wordpress menu items. Decided to post it here as its less likely to disappear.

So I’m assuming that you’ve added FontAwesome to your project in Pinegrow.

First add a new class in your stylesheet in Pinegrow with the following:

/*** CONTACT MENU ICON ***/
.contact-link-icon a:before {
font-family: FontAwesome;
display: inline-block;
padding-right: 6px;
vertical-align: middle;
}

.contact-link-icon a:before {
content: "\f003";
}

Exported your theme then install and activate it in Wordpress and all that has to happen now is display an icon for whatever menu items require them.

So click Appearances > Menus and select the menu you want to add icon(s) to menu items:

54

Then click on Screen Options in the top right corner:

40

this will display a list of options you can activate, tick the box beside CSS Classes. Now when you add or edit a menu item there will be a box called CSS Classes available for you to add your css class.

05

In my example I want to add an envelope beside the menu text “Contact” by adding a class called contact-link-icon

42

Save the change to the menu and visit the fronted of your website and you should now have the icon displaying beside the menu item. This is what it looks like:

17

To add different icons to different menu items just duplicate the above code in your stylesheet and follow the same steps, changing the name of the CSS Class, for example .contact-link-icon a:before could change to .home-link-icon a:before then adding .home-link-icon to the Home menu item in the Wordpress Menu item.

Hope this makes sense and is helpful to someone at some stage.


#2

Hi Rob

Since upgrading to FontAwesome 5.5.0 this suddenly seems to have stopped working for me and I have no idea why. What files would you need to see to help me diagnose the problem?


#3

Hi @jakesmaps I’ve just tried updating FontAwesome to 5.5.0 in a test project and I didn’t have any issues. Basically all I did once I had loaded the FontAwesome library into the project I opened the code view and updated the link to FontAwesome from 5.3.1 to 5.5.0 (before and after screenshots)

and how it looks in a browser afterwards:

21

Copy this if your feeling very lazy!

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">

I’m not using javascript to display FontAwesome just the CSS version, I don’t know if that makes a difference to you. Let me know how you get on.