Updated: October 31, 2017
Adding inline SVGs in WordPress
Finding the best way to include SVG files in WordPress can be a little confusing. There doesn’t seem to be a clear answer anywhere. This article recommends using get_template_part() but for our particular host and the way we deploy this would cause parsing issues with the opening line of the SVG files. It is an xml tag and our host thinks it is a shorthand php tag and won’t allow it. The method below is based around the Using SVG article by Chris Coyier.
echo file_get_contents( get_template_directory() . '/images/icon.svg' );