Created
May 6, 2016 20:59
-
-
Save rugor/1decc15655891825d15a7024a06d898b to your computer and use it in GitHub Desktop.
PHP: WordPress echo SVG file contents for inline SVG
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/awesome.svg' ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, try using
get_template_directory()
instead ofget_template_directory_uri()
Use something like:
<?php echo file_get_contents(get_template_directory().'/theme/img/chevron-right-solid.svg'); ?>
Sometimes using
get_template_directory_uri()
will throw an SSL errorThen, you can target the SVG and style how you wish.
For example:
CSS might be:
.btn svg { line-height: 1.2; max-height: 1rem;}