Fix for ‘Smells-Like-Facebook’ theme error

After upgrading my WordPress and installing the new theme, “Smells Like Facebook” the first problem I ran into was errors anytime someone posted a comment:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 82
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 83
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 84
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/success/wp-includes/pluggable.php on line 865

Seems that I’m not the only one having this problem, and the theme author appears to be busy, so I took it as a personal challenge to fix the damn thing myself. It only took 2 or 3 hours, but I think I got it. I’m posting it here for other people getting these annoying “Cannot modify header information – headers already sent” errors with the Smells Like Facebook theme.

WARNING:: I am not a coder.  I do not know what I am doing.  Before you attempt the changes below, back up your files, your WordPress database, your email and all your iTunes music!  If you find that this ‘fix’ of mine breaks something else, please post a comment here.  I’ve been testing this fix for a few hours and as far as I can tell, it’s working – but I make no guarantees.

As indicated in the error message, the problem is in the functions.php file, at or about line 12, which reads:

add_filter('comment_text', 'slf_comment_text', 29);
function slf_comment_text($comment) {
echo str_replace("<br>", "<br/>", nl2br($comment));
}

The fix is to change that section to read:

add_filter('comment_text', 'slf_comment_text', 29);
function slf_comment_text($comment) {
if(empty($_POST['comment_post_ID'])) {
echo str_replace("<br>", "<br/>", nl2br($comment));
}
}

Like I posted above – this has worked for me so far.  If you find any problems please post them.

Applies to “Smells Like Facebook” Version 2.4

39 thoughts on “Fix for ‘Smells-Like-Facebook’ theme error

  1. Damn I shouldnt do this while talking Ambien. I kept commenting on the authors site.
    Oh I was on 2.3. There hasn’t even been an announcement about 2.4, what the heck? Anyhow, I made the upgrade and then placed your hack into mine. This is your final test from me. Once more in return?

  2. but something weird happen on my blog…when someone put a comment after they press submit, it goes to a blank screen and on the address bar it shows like this my original wordpress url.

    I use different address between my wordpress folder and my blog apperance.

    Can you tell whats wrong with it?

  3. …It is SAFE MODE ON issue, if you have SAFE MODE turned OFF, then this error doesn’t manifest itself…

    Thanks for working patch!

  4. Hi randy..i’m sorry..you’re very fast to visit in my blog but i did’nt finish yet to edit this theme..hahaha..so please visit my blog again.. i hope that fix for errors..i like your creativity to make bottom bar with image..tell me if you find this script to make bottom bar..thnks

  5. thank your blessing father is my web pleases, almost i am mahu install comes his theme. 5 my times has failed and appear problem likes this.

  6. Hey Randy great site ya got there, just wondering how do ya manage to be able to add so much text in the comments box? On my site I am unable to add as much text as you, any ideas ? Thanks mate

  7. Hey Randy, your code about the odd # that was messing things up, that is brill. Your fix worked great, I used it to fix my problems.Tope bloke Randy

  8. Hey Randy, wow man you seem like a super helpful dude. Much appreciation for taking the time to help everyone out like this. Quick question… I can’t get MY avatar to show up. I’ve set it up at Gravatar.com but it isn’t pulling the picture when I post or comment on my own blog, like yours is. I’m using the same email address that’s in my WP General Settings section. Any guesses what would be up with it?

  9. Hey Randy. Your quick man. Yeah, other peoples are showing… just not mine. Can’t be anything big I’m thinking. I was just thinking that maybe there’s some other place I’m supposed to put my email address or something.

  10. I assume you’re using the newest version of Smells Like Facebook. After some Googling, i’m seeing that others are having the same trouble with Gravatars displaying as you, so i assume it’s a bug in the newer version. I’m still using and older version (i’m afraid to upgrade!). You may want to try clearing your browser-cache in the event you’re just not seeing it yourself. Post a link to your blog and i’ll let you know how it looks from my end..

  11. Thanks Randy for spending time on this little issue for me! Not too many people around like that. I’ve been looking around too and it looks like I’m slightly retarded and set my gravatar to Rated PG and set the maximum rating at my blog to Rated G. All fixed now. Seems to be working, even with the upgraded version that I have. Thanks again man.

  12. Hello! I have a little problem with this theme. I use Facebook like button and it is visible everywere, but not in categories. In first page is visible under every topic, but when I click on some category, there is no facebook like button under topics ( only in categories ) . Do you know why? And I have another problem – when someone like my post, activity ( ex. X likes X on X.com ) is visible only in personal profile, but not in News Feed and the traffic is so low. I see my friends, when like some link from webs ite ( with FB Like funktion ) , but in my blog, when someone like something, there is activity only on his/her profile, but not in news feed to his/her friends. Do you know why? Thank you a lot! Have a nice day!

  13. Hey, just started using this theme for another site. I have a static Home page and separate blog page but for some reason my posts will not show on the Home page under the “All” tab. Any idea what would cause this? I think it’s a setting issue.
    I am logged in as admin and admin is the author of already existing posts.
    Just curious if you might know.
    Thanks

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>