WP Rocket + CDN + FacetWP Template

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add to your (child) theme’s functions.php
// @link https://docs.wp-rocket.me/article/90-getrocketcdnurl

add_filter( ‘facetwp_render_output’, function( $output, $params ) {
if ( function_exists( ‘get_rocket_cdn_url’ ) ) {
$html = $output[‘template’];
$html = str_replace( get_home_url(), get_rocket_cdn_url( get_home_url() ), $html );
$output[‘template’] = $html;
}
return $output;
}, 10, 2 );
{{/gist}}