Skip to content

Instantly share code, notes, and snippets.

@macariojames
Last active September 1, 2019 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macariojames/fced3f8bc6bb65634ea4a642c6f4e571 to your computer and use it in GitHub Desktop.
Save macariojames/fced3f8bc6bb65634ea4a642c6f4e571 to your computer and use it in GitHub Desktop.
WordPress: function to display template directory based on needs, such as CSS, images, js files, etc.
<?php
// echo relevant directory ~mj
function print_dir($type) {
if($type === '')
$dir = get_template_directory_uri();
else if ($type === 'js')
$dir = get_template_directory_uri() . '/public/js/';
else if ($type === 'css')
$dir = get_template_directory_uri() . '/public/css/';
else if ($type === 'images')
$dir = get_template_directory_uri() . '/public/images/';
return $dir;
}
// usage echo print_dir('images');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment