Why is there a bunch of WordPress HTML code in my browser CSV download?
This code cannot run in a shortcode: if ( $_SERVER[‘REQUEST_METHOD’] == ‘GET’ && isset($_GET[‘CSV’]) ) { require_once __DIR__ . ‘/../assets/helpers.php’; // contains csv_download() function csv_download(); } The problem is that by the time a shortcode executes it’s too late to send HTTP headers, and WordPress has already sent the theme header and HTML body tags. … Read more