Skip to main content
WooCommerce guide

How to Add Inline Diagrams to a WooCommerce Store

By ยท Updated ยท 4 read

Overview

WooCommerce runs on WordPress, which means adding inline diagrams uses WordPress's template hierarchy and block-editor patterns. The path depends on whether you're editing themes directly, using a page builder, or relying on the block editor.

Three implementation paths

Path one โ€” direct theme editing. Modify your theme's PHP templates (e.g., `single-product.php`, `single.php` for blog posts) to include the SVG markup directly. Most reliable, fully crawlable, requires PHP/theme familiarity.

Path two โ€” block editor (Gutenberg). Use the "Custom HTML" block to paste an SVG into a post or page. Works for one-off diagrams in blog posts. Less reusable since each instance is a separate block.

Path three โ€” page builder (Elementor, Divi, etc.). Most page builders have an "HTML" or "Code" widget where you can paste inline SVG. Works but adds builder-overhead JavaScript to the page. Less ideal than theme-level inline.

WordPress-specific gotchas

WordPress's `wp_kses` content filter (used in many security plugins) can strip SVG elements from post content under default settings. If your inline SVG is disappearing from saved posts, check whether a security plugin is sanitizing it. The fix is either to allow SVG in the kses allowlist (use the `wp_kses_allowed_html` filter) or to inline SVG via the theme template rather than via post content.

WooCommerce's product short-description and long-description fields are subject to the same content filtering. Inline SVG diagrams on product pages are best added via theme template (`single-product.php` or a custom block) rather than typed into the product description editor.

ImageObject schema on WordPress is typically handled by an SEO plugin (Yoast, RankMath). For diagram-specific ImageObject schema beyond what the plugin provides, add it manually via `wp_head` action or a Custom HTML block.

Frequently asked questions

Do WordPress security plugins block inline SVG?

Some do, by default. Wordfence, iThemes Security, and others may strip SVG from post content as a precaution (since malicious SVGs can include JavaScript). The fix is to whitelist your inline SVGs in the kses filter or to add them via theme template files, which security plugins typically don't filter.

Should I use an SVG-icon plugin or write inline SVG directly?

For a small library of branded icons used repeatedly, an SVG plugin is fine. For unique content diagrams (different SVG per article), write them inline directly โ€” plugins add overhead for no benefit when each diagram is one-off.

Does Gutenberg support inline SVG in custom blocks?

Yes. The Custom HTML block accepts SVG markup. For more reusable patterns, you can register a custom block via a plugin that wraps your SVG in a reusable Gutenberg block โ€” useful if you have a standard diagram template used on many pages.

MG
Written by

Matt is the founder of RunOctopus. He built All Angles Creatures from zero to page-1 rankings in reptile feeder insects in under 60 days using exactly this method โ€” turning a hard, entrenched niche into RunOctopus's proof store for programmatic SEO and AI search citation.

Connect on LinkedIn →

See what Otto would build for your store

Free architecture preview. No card required. Five minutes.

Generate Preview →