Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.