Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress get SVG file contents
<?php echo file_get_contents( get_stylesheet_directory_uri() . '/img/icons/your-logo-file.svg' ); ?>
@npetryk

This comment has been minimized.

Copy link

@npetryk npetryk commented Dec 3, 2019

Wont using the .._uri() variant make file_get_contents fetch the file over the network, rather than from the filesystem? It seems like using get_stylesheet_directory() with file_get_contents is a bit better

@deavy

This comment has been minimized.

Copy link

@deavy deavy commented Feb 11, 2020

Since Wordpres 4.7.0 there is cleaner way for getting files from parent/child theme using these function:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment