First, let me say I made this much harder on myself than it should have been. There was much kicking, screaming, gnashing of teeth and biting of ass on my part over something pretty simple. I wanted to add line breaks in author bio’s / descriptions in a WordPress blog I run.
What Didn’t Work
- I tried just using nl2br(); on the code used to display the author bio in single.php. So instead of the_author_description(); I put nl2br(the_author_description());BZZZTTT Wrong!
- Hmm…Next up I researched a little more and found that the_author_description() was deprecated. The replacement code that should be used is: the_author_meta(‘description’); I thought maybe they took care of the line break issue with the new code. BZZZTTT Wrong!
- Fine. Well maybe nl2br(he_author_meta(‘description’)); will work….BZZZTTT Wrong!
- All right. I thought I found the solution with this post that used a filter to replace the line breaks with html breaks. It may actually work but it didn’t for me. BZZZTTT Wrong AGAIN!
Filters! Duhhh! Why not create my own basic filter?!? So I reverted single.php to the old the_author_description(); code, opened up my functions.php file and added the following function / filter at the end:
Boom! All done. Line breaks are now in the author bio’s.
FML I need to brush up on WordPress and php if I’m going to be running into issues like this…:)