I have a custom post type in my wordpress website named Office. The post type has
- Address :: textarea
- Telephone number :: text field
- Fax :: text field
- Email :: email field
When I type the following in the textarea:
This is a test
with multiple rules
Belgiƫ
He saves the following in the database:
office_address_location":"This is a testrnwith multiple rulesrnBelgiu00eb
How can I make sure he saves the correct format in the database? Or at least show the data in a correct way when I edit the textarea field.
To maintain line breaks in PHP, you can use the
nl2br($string)
function (documentation here). As per the PHP docs:In order to properly store characters with accents, you need to be using the correct charset. Try using
htmlentities($text, ENT_COMPAT, 'UTF-8');
and look at the answer in this question.