block by mapsam 11274295

Inline SVG partial for WordPress

Good for acting on specific pieces of your SVG object instead of just link as an <img> you can bring the entire object into your HTML. You need two things:

  1. SVG file with a double extension ending with .php - e.g. logo.svg.php
  2. WP include statement with the built-in function get_template_part
<?php
get_template_part( 'includes/partials/logo', 'logo.svg' );
?>

That’ll strip off the .php extension and bring in the entire SVG object. Your SVG can be straight up exported from Illustrator or what have you, nothing special in there. But remember you’ll need to give it an ID so you can access it via CSS.

logo.svg.php