Developer guidesYour first result in 2 minutes

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 toYou needTime
Print an icon in your themeEasy SVG 5.02 minutes
Ship your own icon pack as a pluginEasy SVG Pro 1.02 minutes
Add an icon field to a blockEasy SVG Pro 1.0, WordPress 7.13 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.

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.

A new or changed file shows up within a minute: Pro caches each folder's scan for 60 seconds. wp easy-svg icons problems names every file a folder could not use.

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' ),
),

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).

Nothing shows up

Next