WordPress ignores line breaks in user description

I have a problem where WordPress isn’t showing line breaks when I echo the user description. The text shows in one line.

I’m using this line of code to show the user description:

Read More
<?php $user = get_user_by( 'slug', 'admin' ); echo  $user->description ?>

Any idea what could be causing the problem and how to get WordPress to show the line breaks in the user description? Adding <br /> to the description box on user profile settings page doesn’t help.

Related posts

1 comment

  1. I think you could do something like this:

    echo  nl2br($user->description);
    

    To optimize things, you could plug it up so that your user description saves the string using nl2br when saved in the database.

Comments are closed.