customization – Removing Yoast from Specific Template


We have a custom template, content generated by an API so no WordPress edit page, and Yoast is spitting out meta data that is based on our most recent blog post, so entirely unrelated to the custom pages.

I’m trying to remove Yoast from these pages, and haven’t been able to get it to work.
Found this question / answer, and from that I tried this code:

add_action( 'template_redirect', 'remove_wpseo' );
function remove_wpseo() {
    if ( basename( $template ) === 'page-franchisee-profile.php' ) {
        $front_end = YoastSEO()->classes->get( YoastWPSEOIntegrationsFront_End_Integration::class );
        remove_action( 'wpseo_head', ( $front_end, 'present_head' ), -9999 );       
    }
}

But it’s not working for me, it doesn’t seem to be grabbing the template. (I tried to print it to see what the $template was and it was blank).