WP Coder Pro → Icons is a library of named SVG icons. Use them in any snippet’s code with {{svg.name}}, and let editors pick them in the Gutenberg block through an Icon (Icons page) attribute.
All icons are written into one sprite file, icons.svg, and every use on a page is a short reference into it. The browser loads the file once, on the first page that shows an icon, and takes it from cache everywhere else. How it all fits together: SVG Icons in blocks.
Adding icons#
Paste SVG code#
Fill in the Add an icon form:
- Name — how code and blocks find the icon: latin letters, digits, dashes and underscores (
arrow-right). It is suggested from the label as you type. - Label — shown in the block picker and read by screen readers.
- Set — optional group (
Social,Arrows) for filtering the page. - SVG code — paste the icon’s code, e.g. from Figma (Copy as SVG). A preview appears as you type.
Upload files#
Choose several .svg files, or a .zip of them. The file name becomes the icon name (Arrow Right.svg → arrow-right); files that are not usable SVG are reported and skipped.
An icon with a name already in the library is skipped — tick Replace icons with the same name to overwrite it.
What happens on save#
Each icon is cleaned before it is stored, whatever its source:
- scripts, event handlers (
onclick…) and anything that is not an SVG element are removed, - editor leftovers (comments,
<metadata>, Sketch / Inkscape attributes) are dropped, - coordinates are trimmed to 3 decimals — design tools export six or more, often a third of the file, and no screen shows the difference.
The card shows the size of the stored icon.
Using icons in code#
{{svg.check}} the icon
{{svg.check.color}} fills and strokes follow the CSS `color`
{{svg.check.inline}} full markup instead of a reference into icons.svg
{{svg.check.color.inline}} both
In the snippet editor, the Icons button (beside Add Image) opens the library: search, tick Color from CSS or Full markup if you need them, and click an icon to insert it at the cursor. Typing {{ in the HTML editor also offers every icon (and every attribute). The Live Preview shows the icons themselves.
On the Icons page, click the {{svg.…}} code on a card to copy it.
{{svg.…}} works in every snippet — the QuickCode tool does not need to be on. An unknown name prints nothing.
With .color the icon takes the colour of the text around it:
.card__icon { color: #e11d48; }
.card__icon:hover { color: #9f1239; }
Every icon has the class wpc-svg and its own width / height — set a size in CSS to change it:
.card .wpc-svg { width: 32px; height: 32px; }
Letting editors choose#
Add an attribute of type Icon (Icons page) (Attributes tab). In the block, the field lists the icons of this page with a search box. In a Repeater use icon:library_icon. See SVG Icons in blocks for its placeholders, including {{$icon_url}} — the link to the icon for your own <use href="…">.
The sprite file#
The Sprite file box shows icons.svg — its size and a link to it. It is rewritten on every change here, and its address carries a version (icons.svg?v=…), so visitors never get an outdated copy from their cache.
Browsers only follow a <use> into a file on the same domain as the page. If your uploads are served from a CDN on another domain, tick Embed the icons in pages instead: each page then carries the icons it uses, at its end.
Renaming and deleting#
The name is how snippets and blocks find an icon. Renaming or deleting an icon empties every place that uses it — {{svg.old-name}} in code and blocks that picked it print nothing. To change how an icon looks, edit it under the same name.
Moving icons to another site#
- Export icons downloads the whole library as a
.jsonfile; Import it on the other site. - Snippet exports carry their icons. Exporting a snippet (Import / Export page, or the list’s Export action) includes the icons its code uses with
{{svg.…}}, and importing it adds them. An icon of the same name is replaced only when Update item if item already exists is ticked. - Blocks that picked an icon are stored in your posts, not in the snippet export — import the icon library too when you move those.