Your first result in 2 minutes
Three ways to start building with Easy SVG and Easy SVG Pro: print an icon in a theme, ship your own icon pack as a plugin, or add an icon field to a block. Copy the code, run it, see the result.
Pick the thing you want to build. Each path has code you can copy, the output it gives on a real site, and a link to the template it comes from.
| You want to | You need | Time |
|---|---|---|
| Print an icon in your theme | Easy SVG 5.0 | 2 minutes |
| Ship your own icon pack as a plugin | Easy SVG Pro 1.0 | 2 minutes |
| Add an icon field to a block | Easy SVG Pro 1.0, WordPress 7.1 | 3 minutes |
Every icon has an address: collection/slug, for example easy-svg/heart. Pages, blocks and fields store this text. The free library is the collection easy-svg. Keep slugs stable: a page that stores an address shows nothing once that slug is gone.
The commands below use WP-CLI, the wp command. Every step also works in wp-admin; the text says where.
Path 1: Print an icon in your theme
What you build: an inline SVG in a theme template, with an accessible name. Free plugin only.
Switch on the icon library
In wp-admin: Easy SVG → Settings → General, switch on Manage icons. Or:
wp option update easy_svg_settings '{"icons":true}' --format=json
Add an icon
Under Easy SVG → Icons, click Upload and pick an SVG. Name it Heart. The name becomes the slug heart.
From a script, send it to the REST route as an administrator with an application password:
curl -u "admin:APPLICATION PASSWORD" -H "Content-Type: application/json" \
-d '{"label":"Heart","markup":"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21s-7-4.5-9.5-9A5.5 5.5 0 0 1 12 6a5.5 5.5 0 0 1 9.5 6c-2.5 4.5-9.5 9-9.5 9z" fill="currentColor"/></svg>"}' \
https://example.com/wp-json/easy-svg/v1/library/add
The answer lists the library and names the new icon under added:
"added": { "id": 4, "slug": "heart", "wanted": "heart" }
Print it
In a theme template:
<?php
if ( function_exists( 'easy_svg_icon' ) ) {
echo easy_svg_icon( 'easy-svg/heart', array( 'label' => __( 'Liked', 'acme' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput
}
Without PHP, in a post, a widget or a page builder text field:
[easy_svg_icon name="easy-svg/heart" label="Liked"]
What you see: both print the same markup. Output on WordPress 7.1 with Easy SVG 5.0:
<svg class="easy-svg-icon" fill="currentColor" role="img" focusable="false" aria-label="Liked" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 21s-7-4.5-9.5-9A5.5 5.5 0 0 1 12 6a5.5 5.5 0 0 1 9.5 6c-2.5 4.5-9.5 9-9.5 9z" fill="currentColor"/>
</svg>
Leave out label and the icon is decorative: aria-hidden="true" instead of role="img". Add 'size' => '24px' and 'class' => 'acme-icon' for a fixed size and a class of your own:
<svg class="easy-svg-icon acme-icon" style="--easy-svg-icon-size:24px" fill="currentColor" aria-hidden="true" focusable="false" ...>
An unknown address gives an empty string '', so a missing icon never breaks the page. The shortcode takes name, label, class and size.
Template: render-an-icon.php
Every argument of easy_svg_icon() in one file.
Reference: easy_svg_icon()
Arguments, return value, sizes and pitfalls.
Path 2: Ship your own icon pack as a plugin
What you build: a small plugin that carries your icons. Install it on any site with Pro, and the icons appear in the Icon block, in the field and builder integrations and in easy_svg_icon(). Nothing is uploaded by hand.
Get the template
Download only the template folder from the dev setup and give it your name:
curl -sL https://github.com/unleash-wp/easy-svg-dev-setup/archive/refs/heads/main.tar.gz \
| tar -xz --strip-components=2 easy-svg-dev-setup-main/templates/icon-pack-plugin
mv icon-pack-plugin wp-content/plugins/acme-icons
Every folder under icons/ is one collection. The template has one: icons/starter-shapes/ with three SVGs and a manifest.json.
Activate it and switch on Collections
wp plugin activate acme-icons
wp option update easy_svg_pro_features '{"sets":true,"cli":true}' --format=json
In wp-admin: Easy SVG → Settings → Features, switch on Collections and WP-CLI. The command above writes only these two switches and turns every other Pro switch off. On a site you already set up, use the screen instead.
Check it
wp easy-svg icons list
Output:
collection label count origin problems
easy-svg Easy SVG 1 library 0
starter-shapes Starter Shapes 3 plugin acme-icons 0
Then print one:
wp eval 'echo easy_svg_icon( "starter-shapes/circle", array( "class" => "acme-icon" ) );'
<svg class="easy-svg-icon acme-icon" fill="currentColor" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/>
</svg>
The plugin adds its folders through the filter easy_svg_pro_source_dirs.
What you see: the collection Starter Shapes with three icons in the Icon block, under Easy SVG → Icons and in every icon picker. Now rename acme-icons.php, the text domain, the folder icons/starter-shapes and the slug in its manifest.json, and drop in your own SVGs.
wp easy-svg icons problems names every file a folder could not use.Template: icon-pack-plugin
The plugin, its composer.json, a readme and one collection.
Reference: the manifest
Every field of manifest.json, the slug rules and the license fields.
Path 3: Add an icon field to a block
What you build: a block of your own with an icon picker in the sidebar. The block stores the icon address and draws it with easy_svg_icon(), so the page keeps its icon when Pro is deactivated.
Switch on PHP-only blocks under Easy SVG → Settings → Features (key icon_field_blocks). The same switch covers blocks written in JavaScript.
No JavaScript and no build step. WordPress 7.0 draws the block's sidebar from its attributes (supports.autoRegister), and Pro turns every attribute marked 'unleashwp' => array( 'component' => 'icon' ) into an icon picker.
curl -sL https://github.com/unleash-wp/easy-svg-dev-setup/archive/refs/heads/main.tar.gz \
| tar -xz --strip-components=3 easy-svg-dev-setup-main/templates/php-only-block/acme-feature-block.php
mv acme-feature-block.php wp-content/mu-plugins/
The heart of the file:
'iconName' => array(
'type' => 'string',
'label' => 'Icon',
'unleashwp' => array( 'component' => 'icon' ),
),
A block with IconControl in the sidebar and IconToolbarButton in the toolbar, from window.EasySvgPro. Plain script, no build:
curl -sL https://github.com/unleash-wp/easy-svg-dev-setup/archive/refs/heads/main.tar.gz \
| tar -xz --strip-components=2 easy-svg-dev-setup-main/templates/javascript-block
mv javascript-block wp-content/plugins/acme-badge
Add a plugin header to acme-badge-block.php and activate it. The editor script depends on the handle easy-svg-pro-icon-control; Pro registers it on every request, so the block loads even with the switch off.
el( window.EasySvgPro.IconControl, {
label: 'Icon',
value: props.attributes.icon,
collections: [], // empty offers every collection
onChange: ( icon ) => props.setAttributes( { icon: icon } ),
} );
Prefer JSX and block.json? Take templates/javascript-block-jsx: it imports IconControl from @unleash-wp/easy-svg-pro, and its webpack.config.js maps that import to Pro's script. Run npm install && npm run build after you change src/.
What you see: insert Feature (or Badge) in the block editor. The sidebar shows Icon with a Choose icon button that opens the icon library. In the editor, window.EasySvgPro holds api (1), IconControl and IconToolbarButton. On the page, with the title "Fast support" and the icon starter-shapes/circle:
<div class="acme-feature"><svg class="easy-svg-icon acme-feature__icon" fill="currentColor" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/>
</svg><h3>Fast support</h3></div>
Size the icon with the class in your block CSS: .acme-feature__icon { width: 3rem; height: 3rem; }.
Templates: php-only-block, javascript-block and javascript-block-jsx. Guides: PHP-only blocks (the attribute marker and collections) and JavaScript blocks (every prop of the two components).