0

Every tutorial I've seen on this subject is out of date, so I'm hoping someone here can help me.

I want to style my wp-login.php page with a CSS file. But I'd like to do it in a way that won't get overwritten when Wordpress is updated. From what I can tell, based on the tuts I've read, the best way it to add it using a function in my themes functions.php file. Unfortunately, the code that people have suggested using just doesn't work for me. Here's the code that I've added.

<?php
function custom_login() {
echo '<link rel="stylesheet" href="wplogin/wplogin.css" />';
}
add_action('login_head', 'custom_login');
?>

It does include the stylesheet like I want, but unfortunately I get this error on my page.

Warning: Cannot modify header information - headers already sent by (output started at /home/skyyprod/gointrigue/sandbox/wp-content/themes/rockwell_v1.6/functions.php:899) in /home/skyyprod/gointrigue/sandbox/wp-login.php on line 353

Warning: Cannot modify header information - headers already sent by (output started at /home/skyyprod/gointrigue/sandbox/wp-content/themes/rockwell_v1.6/functions.php:899) in /home/skyyprod/gointrigue/sandbox/wp-login.php on line 365

What am I doing wrong?

1
  • what's on line 899 in your functions.php? that code is correct, your error is elsewhere.
    – Milo
    Sep 10, 2011 at 2:19

2 Answers 2

0

"Headers already sent" means that some code tried to set a HTTP header (eg. to set a cookie), but that PHP already sent content that will end up in the HTML page. The most likely cause is that you added extra newlines after the ?> closing tag when you edited config.php or functions.php.

The simple solution it to just remove the closing ?> in these files - it is not required anyway.

1
  • You were close! I had my code above placed after everything in my functions.php file. Removing the <?php ?> from my code and putting it within the <?php ?> that was already there stopped the errors. Thanks.
    – jkupczak
    Sep 10, 2011 at 21:07
0

This error occurs when you manually edit wp-config.php using Notepad OR when you try to send header information after sending something else (header data always goes FIRST, period).

It is hard to tell what you're doing wrong without looking at your functions.php code, but try placing the code at the very beginning of your functions.php file. It should help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.