Here’s how to add an .svg
file to your a template in your WordPress theme – without having to paste the entire file contents:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo file_get_contents( get_stylesheet_directory_uri() . '/img/icons/your-logo-file.svg' ); ?> |
I use this technique to add the main logo to a website. It would normally go in header.php
but would work anywhere.
4 Comments
at
Thanks. It works like a charm. :) cheers.
Perfect thank you !
Is this solution enough secured against XSS attack and other security problems inherent to SVG files and XML ?
Hi Tibow. If your SVG file is know to be clean of any harmful scripts, this technique will work just fine.