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?


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.

| improve this answer | |
  • 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 – user1676224 Jul 29 '15 at 8:31
  • I've added a link to the code reference where the hook is documented. – Jan Beck Jul 29 '15 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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