2

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?

0

1 Answer 1

3

You can filter template_directory_uri:

<?php
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.

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

Your Answer

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

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