I’m trying to create a button that downloads a text file that is generated from a php script.
So far I have:
<?php //Generate text file on the fly
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=savethis.txt");
// do your Db stuff here to get the content into $content
print "This is some text...";
print $content;
?>
If I use a hook to show this after the content on a page I get the following error:
Warning: Cannot modify header information – headers already sent by (output started at /home/onecards/public_html/wp-includes/class.wp-styles.php:290) in /home/onecards/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(196) : eval()’d code on line 3
Warning: Cannot modify header information – headers already sent by (output started at /home/onecards/public_html/wp-includes/class.wp-styles.php:290) in /home/onecards/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(196) : eval()’d code on line 4
If I put the code into a .php file and call that with a href link it works.
Thanks!