Is it possible to change the template_directory?

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:

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

Leave a Comment