Skip to content

Instantly share code, notes, and snippets.

@samikeijonen
Last active May 8, 2016 09:35
Show Gist options
  • Select an option

  • Save samikeijonen/00644da70e4b20ce08d4e8dc04746b9a to your computer and use it in GitHub Desktop.

Select an option

Save samikeijonen/00644da70e4b20ce08d4e8dc04746b9a to your computer and use it in GitHub Desktop.
Inline SVG sprite
<body>
<?php
// 1. Include SVG images from assets/images folder right after <body> element.
$svg_icons = get_template_directory() . '/assets/images/svg-icons.svg';
require_once( $svg_icons );
// 2. Include for example Twitter icon from SVG sprite. This can be anywhere in your markup.
?>
<svg class="icon icon-twitter">
<use xlink:href="#twitter-icon"></use>
<svg>
<?php
// 3. Or even better use function _s_get_svg() found in wd_s to generetate the markup.
// @link: https://github.com/WebDevStudios/wd_s/blob/master/inc/template-tags.php#L124
echo _s_get_svg( array( 'icon' => 'twitter' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment