JPKCom FA inline SVG shortcode — Guide & Tips
Output inline SVGs from Font Awesome (Pro) v5.15.4 via a WordPress shortcode — installation, Font Awesome setup and practical tips for the [jsvg] shortcode.
JPKCom FA inline SVG shortcode loads icons from Font Awesome (Pro) v5.15.4 as inline SVG and outputs them via a shortcode — fast and resource-efficient, with no webfont or JavaScript loader. Intended for anyone who wants to integrate the Font Awesome SVG-with-JS package into their WordPress site without fuss.
This is not an official Font Awesome plugin and is not directly affiliated with the vendor. Get a Font Awesome or Font Awesome Pro license at https://fontawesome.com/.
Guide
Requirements
- WordPress 6.9 or newer (tested up to 7.0)
- PHP 8.3 or newer
- Your own copy of Font Awesome (Pro) v5.15.4 (via your Font Awesome license)
- Multisite is supported (the plugin is network-enabled)
Installation
- In your admin panel, go to Plugins → Add New and click Upload Plugin.
- Choose the plugin's ZIP file and click Install Now.
- Download your version of Font Awesome (Pro) v5.15.4 from https://fontawesome.com/.
- Unpack the contents of the Font Awesome archive directly into a folder named
jpkcom_fasvg/underwp-content/uploads. - Make sure the following files/folders are present:
wp-content/uploads/jpkcom_fasvg/css/svg-with-js.min.cssandwp-content/uploads/jpkcom_fasvg/svgs/*. - Click Activate.
Usage
Place the shortcode in your content or in a menu item title:
[jsvg type="" name="" style="" class="" title=""]Example:
[jsvg type="fal" name="jedi" style="margin:2rem" class="fa-10x" title="Obi-Wan Kenobi"]type— the Font Awesome style family (e.g.fas,fal)name— the icon name (e.g.jedi)style— optional inline CSSclass— additional CSS classes (e.g.fa-10x,fa-rotate-270)title— accessible title of the icon
The shortcode can also be used programmatically via do_shortcode():
<?php
echo do_shortcode( '[jsvg type="fas" name="snowboarding" class="fa-4x fa-rotate-270" title="Snowboarding"]' );For more on do_shortcode(), see the WordPress function reference.
Tips & Tricks
- Icon names map to SVG file names: The
namevalue references the file in the respective style directory undersvgs/. If the name doesn't match an existing SVG file, nothing is rendered. - Security of the
nameattribute: Since version 2.0.9 thenamevalue is sanitized withsanitize_file_name()/basename()to prevent path traversal — slashes and path segments in the name won't work. - Usable in menu titles: Since the shortcode also works in menu item titles, you can enrich navigation entries with icons.
- Font Awesome transform classes: Sizing and rotation utilities like
fa-4xorfa-rotate-270can be passed via theclassattribute. - Reproducible updates: Since version 2.0.9 the plugin uses secure self-hosted updates via GitHub with SHA256 checksums and runs with
declare(strict_types=1).
Further reading
- Source code on GitHub: https://github.com/JPKCom/jpkcom-fa-svg-plugin
- API documentation (PHPDoc): https://jpkcom.github.io/jpkcom-fa-svg-plugin/docs/
- Font Awesome (Pro): https://fontawesome.com/
do_shortcode()in the WordPress reference- This project's changelog