I've created a site on a localhost that is going to be migrated to a ssl server, with the scripts, css, images all coming from a CDN.

To call files in the site i'm using bloginfo('template_directory'); is there a way to alter this to fit with the sites requirements?


1 Answer 1


You can filter template_directory_uri:

add_filter( 'template_directory_uri', function( $template_dir_uri ){
    return str_replace( 'http://example.com', 'https://cdn.example.com', $template_dir_uri );

This will change URIs so they point at a CDN subdomain served via HTTPS.

  • Thank you, this was exactly what I needed. I wasn't aware of this filter, for anyone else interested in using this here is a reference link wpseek.com/hook/template_directory_uri Commented Jul 29, 2015 at 8:31
  • I've added a link to the code reference where the hook is documented.
    – Jan Beck
    Commented Jul 29, 2015 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.