• Hello everyone,

    I’m creating a theme and I have created a PHP file that saves as a css file:

    <?php include '../../../wp-blog-header.php'; ?>
    <?php header("Content-type: text/css"); ?>
    
    some normal CSS styles here

    This works fine on my localhost and my web host, but SOME hosts are displaying a “header already sent” error.

    How do I avoid this? I’m guessing it’s because I’m including wp-blog-header.php but this is needed so I can grab WordPress’s functions.

    Also why would this error only fire on some hosts and not all of them?

    wierd…

Viewing 1 replies (of 1 total)
  • If it’s working differently on different hosts, I would guess that it’s due to a difference in the PHP settings on your host.

    Also, almost every time I’ve ever gotten that error it was because I tried to set a PHP header after the HTML tag. If it’s at all possible for you to set the second header before the HTML tag, it will probably work.

Viewing 1 replies (of 1 total)
  • The topic ‘Headers already sent error – how do I avoid?’ is closed to new replies.