Home / Guides / How to Add Icons to WordPress

How to Add Icons to WordPress

GUIDE · 4 MIN READ

Why WordPress blocks SVG uploads

WordPress does not let you upload SVG files through the media library, and that surprises first time users. The reason is safety: an SVG is code, not just a picture, and a malicious file could run scripts on your site. So WordPress blocks the format by default, and the uploader answers with a polite error. This does not mean you cannot use SVG icons on WordPress. It means you use one of two routes: upload a PNG through the media library, or paste SVG code into a Custom HTML block. The PNG route is the simplest and works for everyone. The code route stays sharper and lets you recolour the icon. Both are free, and both take under a minute once you know the steps.

Add an icon with an Image block

The Image block is the easy route. First, download the icon from Icondusk as a PNG. Pick the colour on the set page before you download, because a PNG cannot change colour later. The 128 pixel size is a good default for icons in text, and larger sizes suit feature lists and headers. Then open your post or page in the block editor, click the plus button, choose Image, and upload the PNG. Click the icon to select it, and set the width in the block settings on the right. Use the alignment buttons to centre it, or leave it inline beside a paragraph. A 24 to 48 pixel width suits icons beside text, while 64 pixels suits a feature grid. Keep one width for every icon in a row, so the layout stays even.

Add a sharper icon with a Custom HTML block

For the sharpest result, paste the icon as SVG code. On the set page, open the icon, copy its SVG code, and paste it into a Custom HTML block. The icon renders as real vector shapes, sharp at any size, and you can recolour it by setting the colour on the block, because the icon uses currentColor for its fill. Here is a real icon, the search icon from the Shopping & E-commerce set, pasted as code: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path fill-rule="evenodd" d="M16.5 10a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0zM12.8 10a2.8 2.8 0 1 1-5.6 0 2.8 2.8 0 0 1 5.6 0z"/><path d="M14.6 14.2l1.7-1.7 4.7 4.7a1.2 1.2 0 0 1-1.7 1.7l-4.7-4.7z"/></svg> Add width and height attributes to the svg tag, keeping them equal, so the icon shows at the size you want. Our guide to using SVG icons in HTML and CSS explains the inline method in more depth. One catch: only Administrators and Editors can save this kind of HTML in WordPress. If your role is Author or lower, WordPress strips the code, so use the Image block route instead.

Use the built-in Icon block

WordPress 7.0 added a built-in Icon block, and version 7.1 added a public way to register your own icons. In the block editor, search the block inserter for Icon, add the block, and choose an icon from the picker. You can change its colour, size, and background from the block settings on the right, just like text. The built-in library is small, so it covers common symbols but not specialised ones. For a wider choice, install the free Icon Block plugin, which adds a library of around 300 icons and lets you paste in custom SVG code. If you build themes or plugins, the 7.1 registration functions let you add your own icon collection with code, so your icons appear in the picker for every editor on the site.

Three practical examples

First, a feature list: add three columns, place a 64 pixel PNG icon at the top of each, and write one short benefit under each. The icons turn a plain list into a scannable grid. Second, contact details in the footer: put a small phone icon beside your number and a mail icon beside your email, both in one colour and one size. The icons replace labels, so the footer stays compact. Third, a call to action button: paste a small arrow or download icon as SVG code inside a Custom HTML block next to your button text, and colour it to match the button. The icon draws the eye to the action. In all three cases, use icons from one set, so the stroke weight and corner style match across the page.

Mistakes to avoid

Four mistakes show up again and again. One, trying to upload an SVG through the media library and getting the file type error. Upload a PNG instead, or paste the code. Two, downloading a PNG in the wrong colour and discovering it cannot change. Pick the colour on the set page first. Three, mixing styles on one page, such as a Filled home icon beside an Outline settings icon, which looks accidental. Four, uploading huge PNG files for tiny icons, which slows the page for no benefit. The 128 pixel download is plenty for icons shown at 24 to 64 pixels. Fix these four, and icons will feel like a native part of your WordPress site, not an afterthought.

Every icon mentioned in our guides is free to download from the sets page, SVG and PNG, no attribution required.

Keep reading

More practical guides from the library.