How to echo the contents of an SVG file with PHP

December 30, 2019 , I learned...

Using this is so much cleaner in the template files than copying and pasting the entire SVG code. Plus, it lets me manage all of my SVG files from a central location. Update it once, and the changes are applied everywhere!

<?php echo file_get_contents( get_template_directory_uri() . '/dist/img/logo.svg' ); ?>