Dynamically generating the file path to the template directory

When you start getting deeper into WordPress theme development, you will often have to reference images, includes and other files. To keep things tidy, you should keep all of these in the template folder. Then you can move your theme around different blogs and websites and all the paths will work.

You simply need the piece of code:

1.<?php bloginfo('template_directory'); ?>

This will generate the url to the current template folder dynamically through WordPress. For instance, you may have included some Javascript in your theme, and it’s convenient to keep this all together in a folder called ‘jscript’ within your template directory. Rather than have to hard-code the URL path in your template file, like ‘www.mysite.com/wp-content/themes/mytheme/jscript/script1.js’ you would write this as: